jmschrei / pomegranate

Fast, flexible and easy to use probabilistic modelling in Python.
http://pomegranate.readthedocs.org/en/latest/
MIT License
3.29k stars 590 forks source link

Efficient Tensor conversion from list of numpy arrays #1071

Closed josalhor closed 7 months ago

josalhor commented 7 months ago

While playing around with pomegranate v1 I run into this warning:

/home/josalhor/Desktop/data-synt/venv/lib/python3.11/site-packages/pomegranate/_utils.py:62: UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor. (Triggered internally at ../torch/csrc/utils/tensor_new.cpp:261.)

I think my pull requests fixes that warning and should speed up the casting.

jmschrei commented 7 months ago

Would you mind undoing the version bump? Usually I'll only do a bump after a few changes, and have a corresponding release when I do it.

josalhor commented 7 months ago

Absolutely no problem. Actually, I did the version bump because GitHub Actions reported a cancellation but no failure and wanted to retest. Will undo the commit.

jmschrei commented 7 months ago

Thanks!

josalhor commented 7 months ago

Did this PR break the build?

jmschrei commented 7 months ago

No. There are some unit tests that stochastically raise NaNs. When I manually re-run them they run successfully. 100% of the time these same tests run successfully on my local machine so I'm not sure what their source is.