def test_mul(self):
x = T.dmatrix()
y = T.dmatrix()
f = theano.function([x], T.mul(x), mode=self.mode)
vx = numpy.random.rand(5, 4)
vy = numpy.random.rand(5, 4)
f(vx)
topo = f.maker.fgraph.toposort()
assert len(topo) == 1
assert topo[0].op == deep_copy_op
f2 = theano.function([x, y], T.mul(x, y), mode=self.mode)
assert numpy.all(f2(vx, vy) == vx * vy)
topo2 = f2.maker.fgraph.toposort()
assert len(topo2) == 1
assert isinstance(topo2[0].op, T.Elemwise)
assert isinstance(topo2[0].op.scalar_op, theano.scalar.Mul)
评论列表
文章目录