/home/main.py(64)<module>() -> print(PatchConv2d) (Pdb) p PatchConv2d.forward <function PatchConv2d.forward at 0x79ff23215120> (Pdb) p PatchConv2d.forward.__code__ <code object forward at 0x79ff231d7260, file "/home/main.py", line 33> (Pdb) p dir(PatchConv2d.forward.__code__) ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'co_argcount', 'co_cellvars', 'co_code', 'co_consts', 'co_filename', 'co_firstlineno', 'co_flags', 'co_freevars', 'co_kwonlyargcount', 'co_lines', 'co_linetable', 'co_lnotab', 'co_name', 'co_names', 'co_nlocals', 'co_posonlyargcount', 'co_stacksize', 'co_varnames', 'replace']
ok i tried it using an online python interpreter -> class PatchConv2d(nn.Module): (Pdb) n p PatchConv2d.forward.co_constsconsts *** AttributeError: 'function' object has no attribute 'co_consts' p PatchConv2d.forward.__code__.co_constsconsts (None, 1073741824, 0, 2, 1, 3, 4, 'zeros', 'constant', ('mode', 'value'), -1, ('dim',)) (Pdb) PatchConv2d.forward.__code__.co_consts = PatchConv2d.forward.__codePatchConv2d.forward.__code__.co_consts = PatchConv2d.forward.__code__.co_consts *** AttributeError: readonly attribute the constant i want to change is 1073741824 . Setting this much lower would enable the code for smaller data. It seems the solution would be to construct a new code object with the constant changed, and assign it to the function object.