HI I am new to pytorch.
I use dropout in training, so when I test the data, must I change
to model.eval()? I find I get different accuracy if I don’t add “eval()”
self.lstm = nn.LSTM(input_size, hidden_size, num_layers, batch_first=False, dropout=0.5)
self.keke_drop = nn.Dropout(p=0.5)
self.fc = nn.Linear(hidden_size, num_classes)
Thank you for the help.
Yes, otherwise, dropout layer still masks random outputs and the accuracy might be lower.
Sure, Dropout works as a regularization for preventing overfitting during training.
It randomly zeros the elements of inputs in Dropout layer on forward call.
It should be disabled during testing since you may want to use full model (no element is masked)
Thanks for your information Tzu Wei Huang.
Thanks for your time Jing. You explain very clearly.
You can also choose another choice like model.train(False)
yes. chinese haha
thank you for the reply