Accessing the net's class source code

i just ran several different versions of my network and i saved my models using
i now want to reproduce the experiment with the best accuracy but i don’t remember which version of my network’s Class was used in that experiment.
when i tried to load the model with torch.load() i got the following massage (which exactly describes the situation i’m in):
“you can retrieve the original source code by accessing the object’s source attribute or set Module.dump_patches = True` and use the patch tool to revert the changes.”

problem is i don’t see any “source attribute” in my loaded object and don’t know what the patch tool is.

does enyone know i can i accsess the source code of the network’s class definition that was used when the saved model was created?

thanks alot

1 Like

thanks again

bumping this up again.
still need help on that…

For what it’s worth, if you run a Python interactive session and do

torch.nn.Module.dump_patches = True

…pytorch will save one or more *.patch files which you can read in a text editor. They read like a typical file diff, showing the differences between your current code and what was loaded. You can use the command-line tool “patch” if you want to automatically change your current source files to be the same as the the loaded code - or you can make any changes you feel are necessary manually based on the diff. Or just ignore the warning, if the diff looks like only superficial changes have been made.


Thanks so much!
i will try it soon and update

@docsjoo - thanks so much!
worked perfectly. exactly what i needed.