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

ValueError: The value argument to log_prob must be a Tensor #90

Closed
zhaoguangyuan123 opened this issue Mar 26, 2021 · 8 comments
Closed

Comments

@zhaoguangyuan123
Copy link

zhaoguangyuan123 commented Mar 26, 2021

I use python=3.8 and pytorch=1.8.1 and test the example bernoulli_toy.py
Error happens in the following line in expect.py
log_probs = tensor.distribution.log_prob(tensor)
error is
ValueError: The value argument to log_prob must be a Tensor

Seems .log_prob() wants a tensor object as input.
When I print the 'tensor', it outputs:

x: Stochastic tensor([[0., 0., 0., 0.],
        [0., 0., 0., 1.],
        [0., 0., 1., 0.],
        [0., 0., 1., 1.],
        [0., 1., 0., 0.],
        [0., 1., 0., 1.],
        [0., 1., 1., 0.],
        [0., 1., 1., 1.],
        [1., 0., 0., 0.],
        [1., 0., 0., 1.],
        [1., 0., 1., 0.],
        [1., 0., 1., 1.],
        [1., 1., 0., 0.],
        [1., 1., 0., 1.],
        [1., 1., 1., 0.],
        [1., 1., 1., 1.]]) Batch links: [('x', 16, tensor(0.0625))]

Could you offer some solutions? Thank you

@HEmile
Copy link
Owner

HEmile commented Mar 26, 2021

Hi! What version of the code are you using?

@zhaoguangyuan123
Copy link
Author

zhaoguangyuan123 commented Mar 26, 2021

Hi,
I get a bit confused about version.
But I just git clone your_repo and then do thepip install -e .. The verision is version="0.1.0",

Could you expand on your question if information here is insufficient?

best
guangyuan

@HEmile
Copy link
Owner

HEmile commented Mar 27, 2021

Fair enough. So you cloned the master branch or the DiCE branch?

@zhaoguangyuan123
Copy link
Author

yes, i cloned the master branch.

@HEmile
Copy link
Owner

HEmile commented Mar 29, 2021

Alright, can you try the DiCE branch? The master branch is pretty outdated :) (I am going to improve that soonish)

@zhaoguangyuan123
Copy link
Author

Sure. I am going to check that branch right away and keep u updated.
Thanks

@zhaoguangyuan123
Copy link
Author

zhaoguangyuan123 commented Mar 29, 2021

I tried "git clone --branch dice --single-branch https://github.com/HEmile/storchastic.git"
and then re-run the introduction.py in the examples folder.

However, I still get the same bug.

Did i miss any steps?

best
Guangyuan

@HEmile
Copy link
Owner

HEmile commented Mar 30, 2021

Hi Guanyuan,
You're right, I wasn't running on torch 1.8.1. Looks like they have a breaking change somewhere. I just pushed a fix 4b464df on the dice branch, introduction.py runs properly for me now. Thanks for the report!

@HEmile HEmile closed this as completed Mar 30, 2021
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