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

Merge pull request #3421 from bouthilx/shape_padaxis

More explicit description for axis insertion in shape_padaxis
...@@ -586,7 +586,7 @@ dimensions, see :meth:`_tensor_py_operators.dimshuffle`. ...@@ -586,7 +586,7 @@ dimensions, see :meth:`_tensor_py_operators.dimshuffle`.
.. function:: shape_padaxis(t, axis) .. function:: shape_padaxis(t, axis)
Reshape `t` by adding 1 at the dimension `axis`. Note that this new Reshape `t` by inserting 1 at the dimension `axis`. Note that this new
dimension will be broadcastable. To make it non-broadcastable dimension will be broadcastable. To make it non-broadcastable
see the :func:`unbroadcast`. see the :func:`unbroadcast`.
...@@ -596,6 +596,17 @@ dimensions, see :meth:`_tensor_py_operators.dimshuffle`. ...@@ -596,6 +596,17 @@ dimensions, see :meth:`_tensor_py_operators.dimshuffle`.
:type axis: int :type axis: int
:param axis: axis where to add the new dimension to `x` :param axis: axis where to add the new dimension to `x`
Example:
>>> tensor = theano.tensor.tensor3()
>>> theano.tensor.shape_padaxis(tensor, axis=0)
DimShuffle{x,0,1,2}.0
>>> theano.tensor.shape_padaxis(tensor, axis=1)
DimShuffle{0,x,1,2}.0
>>> theano.tensor.shape_padaxis(tensor, axis=3)
DimShuffle{0,1,2,x}.0
>>> theano.tensor.shape_padaxis(tensor, axis=-1)
DimShuffle{0,1,2,x}.0
.. autofunction:: unbroadcast(x, *axes) .. autofunction:: unbroadcast(x, *axes)
......
...@@ -3955,6 +3955,7 @@ def shape_padleft(t, n_ones=1): ...@@ -3955,6 +3955,7 @@ def shape_padleft(t, n_ones=1):
See Also See Also
-------- --------
shape_padaxis
shape_padright shape_padright
Dimshuffle Dimshuffle
...@@ -3971,6 +3972,7 @@ def shape_padright(t, n_ones=1): ...@@ -3971,6 +3972,7 @@ def shape_padright(t, n_ones=1):
See Also See Also
-------- --------
shape_padaxis
shape_padleft shape_padleft
Dimshuffle Dimshuffle
...@@ -3983,7 +3985,19 @@ def shape_padright(t, n_ones=1): ...@@ -3983,7 +3985,19 @@ def shape_padright(t, n_ones=1):
@constructor @constructor
def shape_padaxis(t, axis): def shape_padaxis(t, axis):
"""Reshape `t` by adding 1 at the dimension `axis`. """Reshape `t` by inserting 1 at the dimension `axis`.
Example
-------
>>> tensor = theano.tensor.tensor3()
>>> theano.tensor.shape_padaxis(tensor, axis=0)
DimShuffle{x,0,1,2}.0
>>> theano.tensor.shape_padaxis(tensor, axis=1)
DimShuffle{0,x,1,2}.0
>>> theano.tensor.shape_padaxis(tensor, axis=3)
DimShuffle{0,1,2,x}.0
>>> theano.tensor.shape_padaxis(tensor, axis=-1)
DimShuffle{0,1,2,x}.0
See Also See Also
-------- --------
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论