About the function "_setup_graph()”
aptx1231 opened this issue · 1 comments
aptx1231 commented
Could you tell me why there must be a call "_setup_graph()" before load this model.
I am a pytorch beginner and hope to get your answers.
The code is here:
`
def load_model(self):
self._setup_graph()
assert os.path.exists('models/epo%d.tar' % self._epoch_num), 'Weights at epoch %d not found' % self._epoch_num
checkpoint = torch.load('models/epo%d.tar' % self._epoch_num, map_location='cpu')
self.dcrnn_model.load_state_dict(checkpoint['model_state_dict'])
self._logger.info("Loaded model at {}".format(self._epoch_num))
def _setup_graph(self):
with torch.no_grad():
self.dcrnn_model = self.dcrnn_model.eval()
val_iterator = self._data['val_loader'].get_iterator()
for _, (x, y) in enumerate(val_iterator):
x, y = self._prepare_data(x, y)
output = self.dcrnn_model(x)
break
`
yhy0258 commented
Another question is that there is no directory "models" to load the pre-trained model.