da-rnn icon indicating copy to clipboard operation
da-rnn copied to clipboard

Evaluation mode missing on validation and predict

Open ljtruong opened this issue 4 years ago • 0 comments

This section in predict() https://github.com/Seanny123/da-rnn/blob/8585806feee7726084bb2f733a3aaefada9c1f2f/main.py#L178-L181 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

ljtruong avatar Aug 19 '20 13:08 ljtruong