What setup is needed to load a model. If I just initialize an instance of learn and invoke load I am getting following exception. Not sure what minimum initialization step before loading a model.
While copying the parameter named 0.weight, whose dimensions in the model are torch.Size([4096]) and whose dimensions in the checkpoint are torch.Size([64, 3, 7, 7]), …
RuntimeError Traceback (most recent call last)
in ()
----> 1 learn.load(‘299_pre_model’)
~/fastai/courses/dl1/fastai/learner.py in load(self, name)
61 def get_model_path(self, name): return os.path.join(self.models_path,name)+’.h5’
62 def save(self, name): save_model(self.model, self.get_model_path(name))
—> 63 def load(self, name): load_model(self.model, self.get_model_path(name))
64
65 def set_data(self, data): self.data_ = data
~/fastai/courses/dl1/fastai/torch_imports.py in load_model(m, p)
20 def children(m): return m if isinstance(m, (list, tuple)) else list(m.children())
21 def save_model(m, p): torch.save(m.state_dict(), p)
—> 22 def load_model(m, p): m.load_state_dict(torch.load§)
23
24 def load_pre(pre, f, fn):
~/src/anaconda3/envs/fastai/lib/python3.6/site-packages/torch/nn/modules/module.py in load_state_dict(self, state_dict)
358 param = param.data
359 try:
–> 360 own_state[name].copy_(param)
361 except:
362 print(‘While copying the parameter named {}, whose dimensions in the model are’
RuntimeError: invalid argument 2: sizes do not match at /opt/conda/conda-bld/pytorch_1503965122592/work/torch/lib/THC/THCTensorCopy.cu:31