TheoreticalEcology / s-jSDM

Scalable joint species distribution modeling
https://cran.r-project.org/web/packages/sjSDM/index.html
GNU General Public License v3.0
67 stars 14 forks source link

ValueError: Expected parameter rate #134

Closed fetafretka closed 7 months ago

fetafretka commented 7 months ago

Hey, Im trying to run a sjSDM model on my sequencing data, the species matrix is in the form of raw number of reads, my enviormental data is zero-skewed transformed, into an idependent skale of 0 to 1. The code i run is:

model <- sjSDM(Y = spec_mat, env = linear(data = data.zs1, formula = ~pH),se = TRUE, family = poisson("log"), sampling = 100L)

and the error i get is: Error in py_call_impl(callable, call_args$unnamed, call_args$named) : ValueError: Expected parameter rate (Tensor of shape (100, 38, 4983)) of distribution Poisson(rate: torch.Size([100, 38, 4983])) to satisfy the constraint GreaterThanEq(lower_bound=0.0), but found invalid values: tensor([[[4.9203e-01, 2.1813e+05, 2.0326e-03, ..., 1.2295e+02, <...truncated...>277e-05, 7.8756e-14, 6.0291e-14], [6.0166e-06, 6.1490e+01, 1.1543e+02, ..., 1.0334e+02, 3.8417e+03, 2.8936e+13], [4.0844e+03, 2.4883e+02, 2.7268e-07, ..., 1.5738e+04, 1.4299e-02, 5.9784e-05], ..., [2.3941e+06, 7.8848e-06, 1.6153e+06, ..., 4.0226e+02, 3.2062e-11, 2.5055e-10], [8.4269e+01, 4.1915e-05, 6.7063e+03, ..., 2.8320e-04, 2.0907e+02, 2.3363e+12], [1.0694e+04, 4.5407e+00, 5.8453e+09, ..., 1.2494e+05, 6.7097e-05, 3.0530e+06]]], grad_fn=) Run reticulate::py_last_error() for details. Timing stopped at: 258.6 21.08 73.03

Could anyone help me with this?

MaximilianPi commented 7 months ago

Hi @fetafretka,

please re-try with a lower learning rate, e.g. sjSDM(...., learning_rate = 0.0001)

fetafretka commented 7 months ago

That seems to have fixed it, im running a sampling = 2 as a test, but at the moment its going through smoothly

MaximilianPi commented 7 months ago

Great!

fetafretka commented 7 months ago

Thanks a lot!