Why do model.train()
and model.eval()
return a reference to the model. What is the intended usage for the return value?
I am using as follows:
model.train()
But this means that in a Jupyter notebook it outputs the model object repr which is unwanted:
LeNet(
(m): Sequential(
(0): Sequential(
(0): Conv2d(1, 20, kernel_size=(5, 5), stride=(1, 1))
(1): BatchNorm2d(20, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace)
(3): MaxPool2d(kernel_size=3, stride=3, padding=0, dilation=1, ceil_mode=False)
(4): Dropout(p=0.25)
)
(1): Sequential(
(0): Conv2d(20, 50, kernel_size=(5, 5), stride=(1, 1))
(1): BatchNorm2d(50, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU(inplace)
(3): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)
(4): Dropout(p=0.25)
)
(2): View()
(3): Linear(in_features=200, out_features=500, bias=True)
(4): BatchNorm1d(500, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(5): ReLU(inplace)
(6): Dropout(p=0.25)
(7): Linear(in_features=500, out_features=10, bias=True)
)
)