cossio / RestrictedBoltzmannMachines.jl

Train and sample Restricted Boltzmann machines in Julia
MIT License
14 stars 3 forks source link

Issue with Int8 overflow #8

Closed cossio closed 2 years ago

cossio commented 2 years ago

This line:

https://github.com/cossio/RestrictedBoltzmannMachines.jl/blob/9456632249d3e33ec39ffe867118f4a77a7adc1e/src/train/initialization.jl#L109

Can result in integer overflow when data is of integer type, particularly for Spin units which are of type Int8. It then will raise an error here:

https://github.com/cossio/RestrictedBoltzmannMachines.jl/blob/9456632249d3e33ec39ffe867118f4a77a7adc1e/src/train/initialization.jl#L116

because it will try to take the sqrt of a negative number.