cgt
cgt copied to clipboard
Random number generation and modules (and simplification again)
It seems that there are still problems with simplification of random number generation operation if they are encapsulated into modules.
The following code prints two last lines equal when simplification is turned on:
import cgt
import cgt.nn as nn
z1 = cgt.randn()
z2 = cgt.randn()
m = nn.Module([cgt.scalar()], [z1, z2])
f = cgt.function([], m([0.]))
print 'A', f()
print 'A', f()
z = cgt.randn(2)
m = nn.Module([cgt.scalar()], [z])
f = cgt.function([], m([0.]) + m([0.]))
print 'B', f()
print 'B', f()