def test_random_state_transfer():
 class Graph:
  def __init__(self, seed=123):
   self.rng = MRG_RandomStreams(seed)
   self.y = self.rng.uniform(size=(1,))
 g1 = Graph(seed=123)
 f1 = theano.function([], g1.y)
 g2 = Graph(seed=987)
 f2 = theano.function([], g2.y)
 g2.rng.rstate = g1.rng.rstate
 for (su1, su2) in zip(g1.rng.state_updates, g2.rng.state_updates):
  su2[0].set_value(su1[0].get_value())
 numpy.testing.assert_array_almost_equal(f1(), f2(), decimal=6)

def test_random_state_transfer ( ) : class Graph : def __init__ ( self , seed = 123 ) : self . rng = MRG_RandomStreams ( seed ) self . y = self . rng . uniform ( size = ( 1 , ) ) g1 = Graph ( seed = 123 ) f1 = theano . function ( [ ] , g1 . y ) g2 = Graph ( seed = 987 ) f2 = theano . function ( [ ] , g2 . y ) g2 . rng . rstate = g1 . rng . rstate for ( su1 , su2 ) in zip ( g1 . rng . state_updates , g2 . rng . state_updates ) : su2 [ 0 ] . set_value ( su1 [ 0 ] . get_value ( ) ) numpy . testing . assert_array_almost_equal ( f1 ( ) , f2 ( ) , decimal = 6 )
test that random state can be transferred from one theano graph to another .