Can someone explain what x = x.view(x.size(0), -1) does in this code?
Created 3 years ago
56
Views
2
Comments
class MyNet(nn.Module):
def init(self):
super(MyNet, self).init()
self.classifier = nn.Sequential(
nn.Linear(784, 48), # 28 x 28 = 784
nn.ReLU(),
nn.Linear(48, 24),
nn.ReLU(),
nn.Linear(24, 10)
)
def forward(self, x):
x = x.view(x.size(0), -1)
x = self.classifier(x)
return x
I want to know what does this x.view(x.size(0), -1) do in this? And it is the MNIST dataset.