Ok. I tried running this on CPU and got this error :

RuntimeError : Assertion `x >= 0. && x <= 1.’ failed. input value should be between 0~1, but got -nan(ind) at …\aten\src\THNN/generic/BCECriterion.c:62

The weird thing is that, my dataset is MNIST and I’m not doing anything weird. it is defined like this :
dataset_train = datasets.MNIST(root='MNIST',
                               train=True,
                               transform = transforms.ToTensor(),
                               download=True)
dataset_test  = datasets.MNIST(root='MNIST', 
                               train=False, 
                               transform = transforms.ToTensor(),
                               download=True)
batch_size = 32
num_workers = 2
dataloader_train = torch.utils.data.DataLoader(dataset_train,
                                               batch_size = batch_size,
                                               shuffle=True,
                                               num_workers = num_workers)

dataloader_test = torch.utils.data.DataLoader(dataset_test,
                                               batch_size = batch_size,
                                               num_workers = num_workers)

and I also use a sigmoid in my decoder, so the output must be in range [0,1]. however, when I tried to get the min and max of my output from decoder, there were nans! both in min and max!
here is the output:
min: 10.0 max: 22.0
epoch (0/20) loss: 0.697066KL: -0.000713 recons 0.697778lr: [0.01]
min: 1.0 max: 27.0
min: 0.0 max: 32.0
min: 0.0 max: 32.0
min: 0.0 max: 32.0
min: 0.0 max: 32.0
min: 0.0 max: 32.0
min: 0.0 max: 32.0
min: 0.0 max: 32.0
min: 0.0 max: 32.0
min: 0.0 max: 32.0
min: 0.0 max: 32.0
min: 0.0 max: 32.0
min: nan max: nan

Why am I getting these nans?