Does this network has 4 layers or 1 layers?

class exampleNet(nn.Module):
    def __init__(self):
        self.layer = torch.nn.Sequential(
            torch.nn.Conv2d(3, 3, 9)

    def forward(self, x):
        x = self.layer(x)
        x = self.layer(x)
        x = self.layer(x)
        x = self.layer(x)
        return x

It has 4 conv layers

1 Like

Your model contains one trainable layer which apparently should be used 4 times in a loop.
Since the number of output channels does not match the number on input channels, your code won’t work currently. Also you’ve forgot to return x in your forward method.


Please correct me if im wrong.
in other words, your networks has FLOP of a network with 4 layer and Parameters of network with one layer