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: Expected value argument #136

Open
Sarahbouclette opened this issue Mar 13, 2024 · 3 comments
Open

ValueError: Expected value argument #136

Sarahbouclette opened this issue Mar 13, 2024 · 3 comments

Comments

@Sarahbouclette
Copy link

Hello,
I tried my best to understand and find a solution but I'm stuck. My problem is that i want to use a poisson distribution on eDNA data. So, each species for each sample is described as its number of reads/Total number of reads of the sample. When i try to run my model:

sjSDM(Y=Occ, env=linear(data=Env, formula=~ Run), spatial=linear(data=SC,formula=~0+Longitude:Latitude),sampling = 5L, se=TRUE, family=poisson('log'), learning_rate = 0.0001)
I have this warning:
"Error in py_call_impl(callable, call_args$unnamed, call_args$named) :
ValueError: Expected value argument (Tensor of shape (3, 16)) to be within the support (IntegerGreaterThan(lower_bound=0)) of the distribution Poisson(rate: torch.Size([3, 3, 16])), but found invalid values:
tensor([[0.0000, 0.8209, 0.0000, 0.0000, 0.0000, 0.0448, 0.0000, 0.0000, 0.0000,
0.0000, 0.0000, 0.0448, 0.0000, 0.0896, 0.0000, 0.0000],
[0.0131, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, 0.0000, 0.0000, 0.0000, 0.9869, 0.0000, 0.0000],
[0.2174, 0.1739, 0.0000, 0.0870, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000,
0.0000, 0.0000, 0.5217, 0.0000, 0.0000, 0.0000, 0.0000]])"

I saw that someone already has this issue and you recommended to change the learning rate and to scale the data. I tried both and it's still not working. Do you have an idea of what can I possibly change?

Thank you

@MaximilianPi
Copy link
Member

Hi @Sarahbouclette,

Could you also share a histogram of your response? It may also be difficult for the optimizer if your response is strongly overdispersed. In this case, you may want to switch to a negative binomial distribution.

@Sarahbouclette
Copy link
Author

Sarahbouclette commented Mar 14, 2024

Yes, here is to examples of response histograms. But I have the same error message with Nbinom.
hist carassius
hist cyprinus carpio

@MaximilianPi
Copy link
Member

Hi @Sarahbouclette,

Sorry, it is hard to say if it is because of the data or because of convergence problems in the model. If this is ok for you, could you please send me your code+data (via email) so I can take a look myself?

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