dcgan-mnist icon indicating copy to clipboard operation
dcgan-mnist copied to clipboard

Make the labels float

Open jeremyfix opened this issue 4 years ago • 0 comments

Running the code fails with

Traceback (most recent call last): File "main.py", line 72, in lossD_real = criterion(output, label) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl result = self.forward(*input, **kwargs) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/loss.py", line 530, in forward return F.binary_cross_entropy(input, target, weight=self.weight, reduction=self.reduction) File "/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py", line 2526, in binary_cross_entropy input, target, weight, reduction_enum) RuntimeError: Found dtype Long but expected Float

It seems binary_cross_entropy (on pytorch 1.7.0 expects FloatTensor not LongTensor. Make the real_label and fake_label float solves the problem.

jeremyfix avatar Jan 20 '21 14:01 jeremyfix