-
-
Notifications
You must be signed in to change notification settings - Fork 105
Do I call Module::forward() or Module::forward_mut()?
Corey Lowman edited this page Aug 20, 2022
·
1 revision
They are both used in different situations for different things:
-
Module::forward()doesn't allow the module to be mutated (i.e. every sub-module will receive&self). -
Module::forward_mut()allows the module to be mutated (i.e. every sub-module will receive&mut self).
In general:
- For training, use
Module::forward_mut(), which will allow Dropout & BatchNorm (and others that have running statistics) to update themselves. - For evaluation/testing use
Module::forward().