Skip to content

About the function "_setup_graph()” #13

Description

@aptx1231

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

`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions