Open m-k-S opened 4 years ago
Can you %debug
in the following cell, u
until you have the culprit tensors in locals, then an inspect the culprit tensors?
Sure:
Could it be something to do with tensor([2])
versus tensor(2)
? Is this my fault?
Try pyro.enable_validation(True)
?
Now I'm getting "The value argument must be within the support" after several dozens of iterations.
Hmm, Poisson.support == constraints.nonnegative_integer
which does not contain 8.3
(BTW would you mind enclosing long listings in <details> ... </details>
?)
One issue I notice is that you are optimizing Uniform(a,b)
in the guide, but the model is fixed to Uniform(0,200)
; if the guide ever sets b > 200
there will be an error. You could use say Exponential(1/200)
in the model instead?
Also note that the model is not being enumerated, so you might as well use Trace_ELBO
.
Got it, thanks for all the tips. It's now saying that the value must be within the support for the mixture assignments (no longer from the Poisson distribution):
I also have this error, but from the original tutorial running on my local laptop...
Python 3.7 pyro-ppl==1.3.0 pyro-api==0.1.1 jupyter-client==5.2.4 jupyter-console==6.0.0
After running: train(n_iter)
...
ValueError: The value argument must be within the support
During handling of the above exception, another exception occurred:
...
ValueError: Error while computing log_prob at site 'obs':
The value argument must be within the support
Trace Shapes:
Param Sites:
Sample Sites:
beta dist 19 |
value 19 |
log_prob 19 |
lambda dist 20 |
value 20 |
log_prob 20 |
z dist 320 |
value 320 |
log_prob 320 |
obs dist 320 |
value 320 |
I have no idea what these errors mean or how to fix them (I am also new to Pyro and DPMMs)...
@jinxmirror13 the "value argument must be within the support" error is usually due to NANs. You could try inserting assert not torch.isnan(x).any()
for various tensors x
in your code. I often do that also for the loss returned from svi: assert not math.isna(loss)
.
Hi fritzo, any advice on what to do if hundreds of iterations in, part of a Pyro param is NAN? You say above you insert assertions, but if the assertions fail, what then? I made a post on the Pyro form (https://forum.pyro.ai/t/svi-step-update-only-specified-parameters-minibatch-elbo-scaling/2211) about this issue, but still having it and googling more lead me here.
Thanks!
@gewirtz
after each svi.step()
you can try something like
for name, param in pyro.get_param_store().named_parameters():
bad = torch.isnan(param).sum().item() + torch.isinf(param).sum().item()
if bad > 0:
print(name, param.shape, bad)
to try to identify where nans first appear
Answered on the forum for better visibility 😄
Issue Description
Hi, I am trying to train a Dirichlet process (Poisson) mixture model in Pyro using the Chinese restaurant process (CRP) formulation [code and data are below]. For inference, I am using SVI. SVI will run fine for ~20-30 seconds on my machine (about 400 iterations), and then throws the following error:
RuntimeError: Invalid index in gather at /pytorch/aten/src/TH/generic/THTensorEvenMoreMath.cpp:657
. This occurs regardless of the number of iterations I set.Environment
I am running this in Google Colab, using Python 3.6, pyro-ppl-0.5.1, torch 1.3.0.
Code Snippet
Dataset is found here: http://www.sidc.be/silso/INFO/snytotcsv.php
The code is: