def test_elemwise4():
""" Test that two vectors can be broadcast to form an outer
product (by performing rank-1 matrix update"""
shape = (3, 4)
a = tcn.shared_constructor(theano._asarray(numpy.random.rand(*shape),
dtype='float32'), 'a')
b = tensor.fvector()
c = tensor.fvector()
f = pfunc([b, c], [],
updates=[(a, (a + b.dimshuffle('x', 0) * c.dimshuffle(0, 'x')))],
mode=mode_with_gpu)
has_elemwise = False
for i, node in enumerate(f.maker.fgraph.toposort()):
has_elemwise = has_elemwise or isinstance(node.op, tensor.Elemwise)
assert not has_elemwise
# let debugmode catch errors
f(theano._asarray(numpy.random.rand(4), dtype='float32'),
theano._asarray(numpy.random.rand(3), dtype='float32'))
评论列表
文章目录