How to solve the last conv_layer and linear layer fitting problem?

I have created a CNN model. But I have a question that if I would use hyperparams to create a CNN
model, I don’t know the output size of the last conv layer. I need to write a code to special compute the output size of the last conv layer?

Assuming you would like to let PyTorch automatically compute the in_features of e.g. the first nn.Linear layer based on the used input shape, you could use the nn.LazyLinear module.

2 Likes

Thank you very much, I have solved this problem