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

InfoGAN model error #100

Open
Sumching opened this issue Apr 4, 2019 · 1 comment
Open

InfoGAN model error #100

Sumching opened this issue Apr 4, 2019 · 1 comment

Comments

@Sumching
Copy link

Sumching commented Apr 4, 2019

dist = torch.distributions.one_hot_categorical.OneHotCategorical(torch.tensor([0.1]*10))

lossf = MutualInformationPenalty()
z = torch.randn(2, 100)
c_cont = torch.randn(2, 30)
c_dis = dist.sample([2])
print(c_dis)

G = InfoGANGenerator(10, 30)
D = InfoGANDiscriminator(10, 30)

fake = G(z, c_dis, c_cont)

score, q_categorical, q_gaussian = D(fake, return_latents=True)

loss = lossf(c_dis, c_cont, q_categorical, q_gaussian)
loss.backward()
> Traceback (most recent call last):
  File "test.py", line 40, in <module>
    loss.backward()
  File "/usr/local/lib/python3.5/dist-packages/torch/tensor.py", line 102, in backward
    torch.autograd.backward(self, gradient, retain_graph, create_graph)
  File "/usr/local/lib/python3.5/dist-packages/torch/autograd/__init__.py", line 90, in backward
    allow_unreachable=True)  # allow_unreachable flag
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

Hi,

There are quite a few errors in the documentation. And it took me a lot of time to build the model correctly.

When I used the above code, there were some errors and I was wondering if it was my usage error.

Thanks.

@avik-pal
Copy link
Member

avik-pal commented Apr 4, 2019

@Aniket1998 could you have a look at the error?

Also @Sumching we would really appreciate if you could point us to the errors in the documentation.

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

2 participants