File tree 1 file changed +3
-2
lines changed
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -214,13 +214,14 @@ def forward(self, x):
214
214
# Check against the validation set
215
215
running_vloss = 0.0
216
216
217
- net .train (False ) # Don't need to track gradents for validation
217
+ # In evaluation mode some model specific operations can be omitted eg. dropout layer
218
+ net .train (False ) # Switching to evaluation mode, eg. turning off regularisation
218
219
for j , vdata in enumerate (validation_loader , 0 ):
219
220
vinputs , vlabels = vdata
220
221
voutputs = net (vinputs )
221
222
vloss = criterion (voutputs , vlabels )
222
223
running_vloss += vloss .item ()
223
- net .train (True ) # Turn gradients back on for training
224
+ net .train (True ) # Switching back to training mode, eg. turning on regularisation
224
225
225
226
avg_loss = running_loss / 1000
226
227
avg_vloss = running_vloss / len (validation_loader )
You can’t perform that action at this time.
0 commit comments