wgan-gp icon indicating copy to clipboard operation
wgan-gp copied to clipboard

D_real.backward(mone) RuntimeError: invalid gradient at index 0 - expected shape [] but got [1]

Open ramesh720 opened this issue 6 years ago • 5 comments

while training wgan-gp i got this error. can you help to sove this . thanks in ADVANCE

image

ramesh720 avatar Jan 04 '19 11:01 ramesh720

had the same issue. You need to make one a scalar not array. Try one = torch.ones([])

DanielLongo avatar Jan 18 '19 05:01 DanielLongo

use

D_real = D_real.mean().unsqueeze(0)

horsepurve avatar Apr 12 '19 09:04 horsepurve

I have the same issue. could you tell me how to do

Harryjun avatar Oct 19 '19 06:10 Harryjun

@ramesh720 Hi, I have the same issue. could you tell me how to do

Harryjun avatar Oct 19 '19 06:10 Harryjun

use

one = torch.tensor(1, dtype=torch.float)
mone = one * -1

demarche avatar Apr 08 '20 02:04 demarche