How to specify the input dimension of pytorch nn.Linear?
For example, I have defined  a model shown below:
class Net(nn.module):
   def __init__():
      self.conv11 = nn.Conv2d(in_channel,out1_channel,3)
      self.conv12 = nn.Conv2d(...)
      self.conv13 = nn.Conv2d(...)
      self.conv14 = nn.Conv2d(...)
      ...
      #Here is the point
      flat = nn.Flatten()
      #I don't want to compute the size of data after flatten, but I need a linear layer.

      fc_out = nn.Linear(???,out_dim)

The problem is the Linear layer, I don't want to compute the size of the input to the Linear layer, but the defining model needs to specify it. How can I solve this problem?

The way I do it is to put in some arbitrary value and let the model throw an error. You will be able to see the number of input features in the error description.
There are other ways to do it as well. You can compute the size by hand and write a comment next to each nn.Conv2d layer depicting the layer output. Before you use the nn.Flatten(), you will have the output, simply multiply all the dimensions except the bacthsize. The resulting value is the number of input features for nn.Linear() layer.
If you don't want to do any of this, you can try torchlayers. A handy package that lets you define pytorch models like Keras.
