|
本帖最后由 爱心觉罗 于 2018-10-15 14:40 编辑
近在使用新版 Pytorch 0.4.0训练 GAN 的时候遇到了这样一个BUG: RuntimeError: Expected object of type torch.DoubleTensor but found type torch.cuda.FloatTensor for argument #2 ‘weight’ 。不说了直接上错误地方的代码:
main.py
- cudnn.benchmark = True
- device = torch.device('cuda:3')
- G = Generator().to(device)
- D = Discriminator().to(device)
复制代码 main.py
- for epoch in range(num_epochs):
- for t, x in enumerate(loader):
- optimizerD.zero_grad()
- optimizerG.zero_grad()
- x.requires_grad_().to(device)
- noise_size = x.shape[0]
- noise = torch.randn(noise_size, 1, 28, 28).requires_grad_().to(device)
复制代码
|
|