Hi, my model returns a NAN, i’m using the torchvision datasets api to get the MNIST dataset.
Then I expend the 28x28 images in an extra dimension with
torch.einsum('i,jkl->jikl', vector, img)

where vector is array of ones with zeros on the front and back
the resulting shape is (B, C, D, H, W) = (1, 1, 28, 28, 28) and looks like:
image703×455 14 KB
The model i’m using is defined as:
class ConvAutoEncoder4(torch.nn.Module):
    def __init__(self):
        super(ConvAutoEncoder4, self).__init__()
        channels = 4
        self.fcn3 = nn.Conv3d(in_channels=1, out_channels=channels, kernel_size=4, stride=4)
        self.fcn4 = nn.Conv3d(in_channels=channels, out_channels=channels, kernel_size=1)
        self.fcn5 = nn.Conv3d(in_channels=channels, out_channels=channels, kernel_size=1)
        self.fcn6 = nn.ConvTranspose3d(in_channels=channels, out_channels=1, kernel_size=4, stride=4)
        
    def forward(self, tensor):
        
#         for slc in tensor[0][0]:
#             print(slc)
        
#         print(tensor.shape)
        tensor = self.fcn3(tensor)
        tensor = torch.relu(tensor)
        print(tensor.shape)
        for slc in tensor[0][0]:
            print(slc)
        tensor = self.fcn4(tensor) 
###        NOW IT CONTAINS NANS???
        print(tensor.shape)
        for slc in tensor[0][0]:
            print(slc)
        tensor = torch.relu(tensor)
        tensor = self.fcn5(tensor)
        tensor = torch.relu(tensor)
#         print(tensor.shape)
        tensor = self.fcn6(tensor)
        tensor = torch.relu(tensor)
#         print(tensor.shape)
#         for slc in tensor[0][0]:
#             print(slc)
        return tensor

Now the NAN’s are arising in the second image alread usually around the second layer.
I don’t understand why, the 1x1x1 kernel should be ok right?
I tried this on the original 2D dataset before and that worked fine.