Using a target size (torch.Size([1, 55, 46, 46])) that is different to the input size (torch.Size([1, 55, 47, 47])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size

I am getting error /usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:47: UserWarning: Using a target size (torch.Size([1, 55, 46, 46])) that is different to the input size (torch.Size([1, 55, 47, 47])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size. . My input size is (1,55,46,46) but i dont know why i am getting [1, 55, 47, 47] and unable to change it to (1,55,46,46)?

class AutoEncoder(nn.Module):
  def __init__(self):
    super(AutoEncoder, self).__init__()
    self.encoder = nn.Sequential(
            nn.Conv2d(55, 16, 3, stride=1, padding=1),  # b, 16, 10, 10
            nn.ReLU(True),
            nn.MaxPool2d(2, stride=1),  # b, 16, 5, 5
            nn.Conv2d(16, 8, 3, stride=1, padding=1),  # b, 8, 3, 3
            nn.ReLU(True),
            nn.MaxPool2d(2, stride=1)  # b, 8, 2, 2
        )
    self.decoder = nn.Sequential(
            nn.ConvTranspose2d(8, 16, 3, stride=1),  # b, 16, 5, 5
            nn.ReLU(True),
            nn.ConvTranspose2d(16, 8, 5, stride=1, padding=1),  # b, 8, 15, 15
            nn.ReLU(True),
            nn.ConvTranspose2d(8, 55, 2, stride=1, padding=1),  # b, 1, 28, 28
            nn.Tanh()
        )
  def forward(self, x):
    x = self.encoder(x)
    print(x.shape)
    x = self.decoder(x)
    print(x.shape)
    return x

How did you calculated those values: # b, 16, 10, 10

If your input is:

input = torch.rand((1,55,46,46))

and you process this input through encoder you will get different shapes than those in your comments

conv_1 = Conv2d(55, 16, 3, stride=1, padding=1)  
t1 = conv_1(input)
t1.size()
>>>torch.Size([1, 16, 46, 46])