PyTorch: get input layer size
I want to programatically find the size of my input layer.

If my first layer is called fc1, how do I find out its input?

Assuming your model is called model, this will give the number of input features of the fc1 layer:

model.fc1.in_features


This is useful inside the .forward() method:

def forward(self, x):
    x = x.view(-1, self.fc1.in_features)  # resize the input to match the input layer
    ...

