pronobis / libspn

Library for learning and inference with Sum-product Networks
Other
23 stars 3 forks source link

High memory usage and slow runtime for generating weights & ops? #61

Closed Lapayo closed 5 years ago

Lapayo commented 5 years ago

While experimenting with various SPN sizes I encountered the problem, that the runtime quickly gets very slow. For example using the following SPN (24k nodes) on an i7 machine:

gen = spn.DenseSPNGenerator(num_decomps=2, num_subsets=2, num_mixtures=2)
iv_x = spn.IVs(num_vars=20, num_components=4)
root = gen.generate(iv_x)

class_roots = [gen.generate(iv_x) for _ in range(10)]
root = spn.Sum(*class_roots)

After generating all required weights and ops the process takes already about 17gb of memory without having any training data loaded yet.

Those numbers seem very high to me - especially the runtime for accumulate_updates and the total memory usage.

Am I underestimating the work load or is there something wrong? I attached the used IPython notebook I used for time measurements for reference.

I would be very glad if someone could take a look and tell me if I am doing anything wrong or if this is normal.

Thanks in advance!

Kind regards, Simon

jostosh commented 5 years ago

Hi Simon,

The current graph generation doesn't scale very well when using more than a single decomposition. Not sure if you are familiar with the exact meaning of num_decomps, but the decompositions are made recursively, so size of the network grows exponentially with base num_decomps ( so roughly 2^n in the snippet above). Your SPNs will be more scalable once you fix num_decomps at 1.

So yes, it is normal what you see.

You can contact me: jos.vandewolfshaar@gmail.com. I can give you some proper advise on how to use the library right now. That will make it easier than to explain everything in this thread.

Best, Jos