Load pytorch model from different working directory
I want to load and access a pretrained model from the directory outside where all files are saved. Here is how directory structure is:

-MyProject
----Model_checkpoint_and_scripts
------access_model.py
--run_model.py
--other files


When run model calls access_model.py it looks for model.py in current working directory and does not find it. As suggested here, I could use

the_model = TheModelClass(*args, **kwargs)
the_model.load_state_dict(torch.load(PATH))


But in this case what is a good way to save all the arguments to initialize the model? I am thinking to pickle the command line args but there are some arguments like vocab size which are calculated.

Thanks

I was able to load it by adding the following lines:

here = os.path.dirname(os.path.abspath(__file__))
sys.path.append(here)

