Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About the function "_setup_graph()” #13

Open
aptx1231 opened this issue Jan 12, 2021 · 1 comment
Open

About the function "_setup_graph()” #13

aptx1231 opened this issue Jan 12, 2021 · 1 comment

Comments

@aptx1231
Copy link

aptx1231 commented Jan 12, 2021

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
Copy link

yhy0258 commented Mar 16, 2023

Another question is that there is no directory "models" to load the pre-trained model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants