Pytorch tutorial max pooling reuse

I transferred from TensorFlow recently. In this tutorial, there is a snippet:

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(3, 6, 5)
        self.pool = nn.MaxPool2d(2, 2)
        self.conv2 = nn.Conv2d(6, 16, 5)

    def forward(self, x):
        x = self.pool(F.relu(self.conv1(x)))
        x = self.pool(F.relu(self.conv2(x)))
        return x

I have two questions:

  1. Will the max pooling in two different layers share the same weights?
  2. If not, how would PyTorch know they are different?

Thank you in advance.

That is because MaxPool2d has no trainable parameters.
image
see, output nothing.

2 Likes

How did I forget that!