pyro-ppl / pyro

Deep universal probabilistic programming with Python and PyTorch
http://pyro.ai
Apache License 2.0
8.58k stars 986 forks source link

Sparse regression example fails for certain input parameters with ZeroDivisionError #2082

Open neerajprad opened 5 years ago

neerajprad commented 5 years ago

e.g.

>>> python examples/sparse_regression.py --num-steps=2 --num-data=50 --num-dimensions 30

Traceback (most recent call last):
  File "examples/sparse_regression.py", line 321, in <module>
    main(args)
  File "examples/sparse_regression.py", line 285, in main
    pyro.param('auto_var_obs').double())
  File "/Users/npradhan/miniconda3/envs/pytorch-36/lib/python3.6/site-packages/torch/autograd/grad_mode.py", line 49, in decorate_no_grad
    return func(*args, **kwargs)
  File "examples/sparse_regression.py", line 172, in compute_posterior_stats
    active_quadratic_dims = np.split(active_quadratic_dims, active_quadratic_dims.shape[0])
  File "<__array_function__ internals>", line 6, in split
  File "/Users/npradhan/miniconda3/envs/pytorch-36/lib/python3.6/site-packages/numpy/lib/shape_base.py", line 854, in split
    if N % sections:
ZeroDivisionError: integer division or modulo by zero

I observed that active_quadratic_dims tensor has 0 sized dims (I'm not sure if this is a pytorch-1.3 issue).

cc. @martinjankowiak

martinjankowiak commented 5 years ago

hmm, i don't see this on torch 1.2.0....