Get the input channels for the conv2d from previous layer?
I was wondering if there are many convolutional layers (conv1 --> conv2 ). How can we get the input channels parameter for the conv2 from the conv1 output channel?

class MyModel(nn.Module):
  def __init__(self, in_ch, num_features, out_ch2):
    super(MyModel, self).__init__()
    self.conv1 = nn.Conv2D(in_channels,num_features)
    self.conv2 = nn.Conv2D(in_channnels_from_out_channels_of_conv1,out_ch2)


Can I get the out_channels from the conv1 layer and use it as in_ch for conv2?

Second parameter of nn.Conv2D constructor is number of output channels:

self.conv1 = nn.Conv2D(in_channels,conv1_out_channels)
self.conv2 = nn.Conv2D(conv1_out_channels,out_ch2)


as described in the docs

Also it available as a property:

self.conv1.out_channels

