def forward(self, images):
    images=images.unsqueeze(dim=1)
    x = self.layer_1(images)
    x = self.layer_2(x)
    x = x.view(x.size(0), -1)
    .
    .
    .

You need to perform the step before you begin passing it into the network.