提交 a184bf73 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

Adding any and all to tensors

上级 31c1c6a2
......@@ -1232,6 +1232,12 @@ class _tensor_py_operators:
size = property(lambda self: prod(self.shape))
# We can't implement __len__ to provide a better error message.
def any(self, axis = None):
return elemwise.Any(axis)(self)
def all(self, axis = None):
return elemwise.All(axis)(self)
# Otherwise TensorVariable[:-1] does not work as Python 2.5.1 calls
# __len__ before calling __getitem__. It also does not catch the raised
# Exception!
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论