def test_map(self):
v = theano.tensor.vector('v')
abs_expr, abs_updates = theano.map(
lambda x: abs(x),
v,
[],
truncate_gradient=-1,
go_backwards=False)
f = theano.function([v],
abs_expr,
updates=abs_updates,
allow_input_downcast=True)
rng = numpy.random.RandomState(utt.fetch_seed())
vals = rng.uniform(size=(10,), low=-5., high=5.)
abs_vals = abs(vals)
theano_vals = f(vals)
utt.assert_allclose(abs_vals, theano_vals)
评论列表
文章目录