提交 edf6fb5a authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #1490 from mrocklin/abs_

use absolute reference for abs_
......@@ -6449,6 +6449,12 @@ class TestTensorInstanceMethods(unittest.TestCase):
# Test equivalent advanced indexing
assert_array_equal(X[:,indices].eval({X: x}), x[:,indices])
def test_norm():
x = theano.tensor.vector('x')
n = x.norm(2)
f = theano.function([x], n)
assert numpy.allclose(f([1, 1]), numpy.sqrt(2))
if __name__ == '__main__':
t = TestInferShape('setUp')
......
......@@ -462,7 +462,8 @@ class _tensor_py_operators:
raise NotImplementedError()
# optimizations will/should catch cases like L=1, L=2
return theano.tensor.basic.pow(
theano.tensor.basic.pow(abs_(self), L).sum(axis=axis), 1.0 / L)
theano.tensor.basic.pow(
theano.tensor.basic.abs_(self), L).sum(axis=axis), 1.0 / L)
def mean(self, axis=None, dtype=None, keepdims=False, acc_dtype=None):
"""See `theano.tensor.mean`"""
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论