def test_consistency_randomstreams():
 seed = 12345
 n_samples = 5
 n_streams = 12
 n_substreams = 7
 test_use_cuda = [False]
 if cuda_available:
  test_use_cuda.append(True)
 for use_cuda in test_use_cuda:
  samples = []
  rng = MRG_RandomStreams(seed=seed, use_cuda=use_cuda)
  for i in range(n_streams):
   stream_samples = []
   u = rng.uniform(size=(n_substreams,), nstreams=n_substreams)
   f = theano.function([], u)
   for j in range(n_samples):
    s = f()
    stream_samples.append(s)
   stream_samples = numpy.array(stream_samples)
   stream_samples = stream_samples.T.flatten()
   samples.append(stream_samples)
  samples = numpy.array(samples).flatten()
  assert numpy.allclose(samples, java_samples)

def test_consistency_randomstreams ( ) : seed = 12345 n_samples = 5 n_streams = 12 n_substreams = 7 test_use_cuda = [ False ] if cuda_available : test_use_cuda . append ( True ) for use_cuda in test_use_cuda : samples = [ ] rng = MRG_RandomStreams ( seed = seed , use_cuda = use_cuda ) for i in range ( n_streams ) : stream_samples = [ ] u = rng . uniform ( size = ( n_substreams , ) , nstreams = n_substreams ) f = theano . function ( [ ] , u ) for j in range ( n_samples ) : s = f ( ) stream_samples . append ( s ) stream_samples = numpy . array ( stream_samples ) stream_samples = stream_samples . T . flatten ( ) samples . append ( stream_samples ) samples = numpy . array ( samples ) . flatten ( ) assert numpy . allclose ( samples , java_samples )
verify that the random numbers generated by mrg_randomstreams are the same as the reference implementation by lecuyer et al .