@@ -1360,43 +1450,51 @@ class _tensor_py_operators:
...
@@ -1360,43 +1450,51 @@ class _tensor_py_operators:
size=property(lambdaself:prod(self.shape))
size=property(lambdaself:prod(self.shape))
# We can't implement __len__ to provide a better error message.
# We can't implement __len__ to provide a better error message.
defany(self,axis=None):
defany(self,axis=None):
returnelemwise.Any(axis)(self)
returnelemwise.Any(axis)(self)
defall(self,axis=None):
defall(self,axis=None):
returnelemwise.All(axis)(self)
returnelemwise.All(axis)(self)
# Otherwise TensorVariable[:-1] does not work as Python 2.5.1 calls
# Otherwise TensorVariable[:-1] does not work as Python 2.5.1 calls
# __len__ before calling __getitem__. It also does not catch the raised
# __len__ before calling __getitem__. It also does not catch the raised
# Exception!
# Exception!
# def __len__(self):
# def __len__(self):
# # We can't implement __len__ as Python requests that this
# # We can't implement __len__ as Python requests that this
# # function returns an integer >=0
# # function returns an integer >=0
# raise Exception("Theano Variables can't work with len(Theano "
# raise Exception("Theano Variables can't work with len(Theano "
# "Variable) due to Python restriction. You can use "
# "Variable) due to Python restriction. You can use "
# "TheanoVariable.shape[0] instead.")
# "TheanoVariable.shape[0] instead.")
defreshape(self,shape,ndim=None):
defreshape(self,shape,ndim=None):
"""Return a reshaped view/copy of this variable.
"""Return a reshaped view/copy of this variable.
:param shape: something that can be converted to a symbolic vector of integers
:param shape: something that can be converted to a symbolic vector of
integers
:param ndim: the length of the shape. Passing None here means for theano to try and
:param ndim: the length of the shape. Passing None here means for
guess the length of `shape`.
theano to try and guess the length of `shape`.
"""
"""
returnreshape(self,shape,ndim=ndim)
returnreshape(self,shape,ndim=ndim)
defdimshuffle(self,*pattern):
defdimshuffle(self,*pattern):
"""Reorder the dimensions of this variable, optionally inserting broadcasted dimensions.
"""
Reorder the dimensions of this variable, optionally inserting
broadcasted dimensions.
:param pattern: list/tuple of int mixed with 'x' for broadcastable dimensions
:param pattern: list/tuple of int mixed with 'x' for broadcastable
dimensions
For example, to create a 3D view of a [2D] matrix, call ``dimshuffle([0,'x',1])``. This
For example, to create a 3D view of a [2D] matrix, call
will create a 3D view such that the middle dimension is an implicit broadcasted
``dimshuffle([0,'x',1])``. This will create a 3D view such that the
dimension. To do the same thing on the transpose of that matrix, call ``dimshuffle([1,
middle dimension is an implicit broadcasted dimension. To do the same
'x', 0])``.
thing on the transpose of that matrix, call
``dimshuffle([1, 'x', 0])``.
This function supports the pattern passed as a tuple, or as a variable-length argument (e.g. ``a.dimshuffle(pattern)`` is equivalent to ``a.dimshuffle(*pattern)`` where ``pattern`` is a list/tuple of ints mixed with 'x' characters).
This function supports the pattern passed as a tuple, or as a
variable-length argument (e.g. ``a.dimshuffle(pattern)`` is equivalent
to ``a.dimshuffle(*pattern)`` where ``pattern`` is a list/tuple of ints