示例#1
0
 def test_align(self):
     m = pm.Minibatch(np.arange(1000), 1, random_seed=1)
     n = pm.Minibatch(np.arange(1000), 1, random_seed=1)
     f = theano.function([], [m, n])
     n.eval()  # not aligned
     a, b = zip(*(f() for _ in range(1000)))
     assert a != b
     pm.align_minibatches()
     a, b = zip(*(f() for _ in range(1000)))
     assert a == b
     n.eval()  # not aligned
     pm.align_minibatches([m])
     a, b = zip(*(f() for _ in range(1000)))
     assert a != b
     pm.align_minibatches([m, n])
     a, b = zip(*(f() for _ in range(1000)))
     assert a == b
 def test_align(self):
     m = pm.Minibatch(np.arange(1000), 1, random_seed=1)
     n = pm.Minibatch(np.arange(1000), 1, random_seed=1)
     f = theano.function([], [m, n])
     n.eval()  # not aligned
     a, b = zip(*(f() for _ in range(1000)))
     assert a != b
     pm.align_minibatches()
     a, b = zip(*(f() for _ in range(1000)))
     assert a == b
     n.eval()  # not aligned
     pm.align_minibatches([m])
     a, b = zip(*(f() for _ in range(1000)))
     assert a != b
     pm.align_minibatches([m, n])
     a, b = zip(*(f() for _ in range(1000)))
     assert a == b