Using convolutions without specifying input_channels

Is there a way to use nn.Conv2d without specifying the number of input channels?

You could try something like Inferring shape via flatten operator , but it’s a workaround. PyTorch defines the graph dynamically, so it requires you to specify the number of input channels beforehand.