Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Evaluation mode missing on validation and predict #21

Open
ljtruong opened this issue Aug 19, 2020 · 0 comments
Open

Evaluation mode missing on validation and predict #21

ljtruong opened this issue Aug 19, 2020 · 0 comments

Comments

@ljtruong
Copy link

ljtruong commented Aug 19, 2020

This section in predict()

da-rnn/main.py

Lines 178 to 181 in 8585806

y_history = numpy_to_tvar(y_history)
_, input_encoded = t_net.encoder(numpy_to_tvar(X))
y_pred[y_slc] = t_net.decoder(input_encoded, y_history).cpu().data.numpy()

should be changed to

with torch.no_grad():
  y_history = numpy_to_tvar(y_history)
  _, input_encoded = t_net.encoder(numpy_to_tvar(X))
  y_pred[y_slc] = t_net.decoder(input_encoded, y_history).cpu().data.numpy()

This is required to disable any gradient calculation during validation / prediction in training loop. From my understanding if not included, it wll update weights on each validation / prediction iteration.

This is original final_prediction output
original

This is with grad turned off during validation / prediction.
grad off

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

No branches or pull requests

1 participant