def test_xor(self):
for dtype in self.dtype:
x, y = vector(dtype=dtype), vector(dtype=dtype)
fn = inplace_func([x, y], x ^ y)
ix = x
ix = inplace.xor_inplace(ix, y)
gn = inplace_func([x, y], ix)
l = theano._asarray([0, 0, 1, 1], dtype=dtype)
r = theano._asarray([0, 1, 0, 1], dtype=dtype)
v = fn(l, r)
self.assertTrue(numpy.all(v == (operator.xor(l, r))), (l, r, v))
v = gn(l, r)
# test the in-place stuff
self.assertTrue(numpy.all(l == numpy.asarray([0, 1, 1, 0])), l)
评论列表
文章目录