Hi, ptrblck
I use BCE for optimizing my GAN, and I create the target by myself with the following code so I pretty sure it’s within the range[0, 1]
# for real samples
if idx % 3 == 0:
label = torch.full([batch_size, ], 0.0, device=self.device)
else:
label = torch.full([batch_size, ], 1.0, device=self.device)
# for fake samples
if idx % 3 == 0:
label.fill_(1.0)
else:
label.fill_(0.0)
However, when I was debugging, I found the network outputted [[[[nan…, …]]]] when the assertion occured. It’s caused by the one of the conv layers, I put a screen shot and code below:
As you can see “out” is the output from that conv layer, and the input of that layer is “x”, which is the image and I normalize it to range [-1, 1].
the code of the conv layer is:
self.in_convs = nn.Sequential(nn.Conv2dh3, 32, kernel_size=3, stride=2, padding=1, bias=False),
nn.BatchNorm2d(32),
nn.ReLU(inplace=True),
nn.Conv2d(32, 64, kernel_size=3, stride=1, padding=1, bias=False),
nn.BatchNorm2d(64),
nn.ReLU(inplace=True))
I don’t know what is going on as I think my code is right. And before I change my cpu and motherboard. everything worked fine. Thank you so much