Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ramesh720 opened this issue Jan 4, 2019 · 5 comments

Comments

@ramesh720
Copy link

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

image

@DanielLongo
Copy link

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

@horsepurve
Copy link

horsepurve commented Apr 12, 2019

use

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

@Harryjun
Copy link

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

@Harryjun
Copy link

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

@demarche
Copy link

demarche commented Apr 8, 2020

use

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants