[Haskell-beginners] CAF taking all the memory

Mahdi mdibaiee at aol.com
Mon May 2 18:55:20 UTC 2016


Hello there,

I’m pretty new to Haskell and I’m trying to write a Neural Network in Haskell for educational purposes.

So, I have my neural network working, it can learn XOR in 500 iterations, but the thing is, if I increase the iterations to something like 5 milion times,
the process just drains my RAM until either it’s killed or the OS drowns. Here is the code: [0]

I searched online and tried to get information on why this is happening, I profiled the memory usage and found that the memory is taken by CAF, searching online,
it seems like an optimization done by compiler to reduce runtime computations. Here is the profile: [1]

I searched online on how to prevent this from happening, couldn’t find anything helpful.

I found this [2] and tried the workaround, but it didn’t work.

Is there any way to solve this problem? Because when I’m moving to more complex problems, I have to train with much more iterations, and it just doesn’t work.

[0] https://github.com/mdibaiee/biscuit/blob/master/src/examples/xor.hs
[1] https://gist.github.com/mdibaiee/95878469a80f1c448b8cf0762178720e
[2] http://stackoverflow.com/questions/6090932/how-to-make-a-caf-not-a-caf-in-haskell

Thank you,
– Mahdi


More information about the Beginners mailing list