Hi all,
I’m pretty new to pytorch, so I apologize if the question is very basic.
I have a model where, for each layer, I set the number of features, but the input image size is not fixed (it can change among trainings).
The last layer of my model is a 2D convolution that converts n input features to 1 value per pixel. To do this I would use a linear activation function.
The question is:
how to dynamically set the input/output number of features of a linear function considering that the input image can change among trainings and only the number of features is fixed?
From my opinion, it is better to have a fixed input shape. If the layers you are mentioned is convolution layers. Then it can generally handle multiple shapes. Can you provide more information on this question ? The convolution parameters are generally fixed and it doesn’t change on the input shape.
I use the same code to train different models over different set of images having different shapes (among datasets, of course).
So, if the final 2D convolution has 32 features as output, and the image has shape 512x512, I have to initialize the linear module to 32x512x512 input features and 1x512x512 a output features?
Do I need also a “view” to reshape the output to 512x512 shape?
What if I do not set any activation function for a 2D convolution?
Which is the default one?
Can you share the architecture ? The linear module has only two parameters. Input and output dimensions. Ideally the fully connected ( linear ) will not have input dimension 32512512 (single number) because the number is huge. So repeated convolution and max pooling is carried before using linear layer. View command is used to flatten the convolution layer features into a single dimension by handling batch size. So if it is used the feature map (4x32x512x512) will become (4x(32x512x512)). Here 4 denotes batch size.