提交 9853268d authored 作者: Frederic Bastien's avatar Frederic Bastien

[Interface change] tensor.flatten() deprecate outdim and rename it to ndim to be…

[Interface change] tensor.flatten() deprecate outdim and rename it to ndim to be more consistent with the rest of Theano include var.flatten() that use ndim.
上级 e5d09827
...@@ -5086,7 +5086,7 @@ def is_flat(var, outdim=1): ...@@ -5086,7 +5086,7 @@ def is_flat(var, outdim=1):
return var.ndim == outdim return var.ndim == outdim
def flatten(x, outdim=1): def flatten(x, ndim=None, outdim=None):
""" """
Reshapes the variable x by keeping Reshapes the variable x by keeping
the first outdim-1 dimension size(s) of x the same, the first outdim-1 dimension size(s) of x the same,
...@@ -5098,14 +5098,21 @@ def flatten(x, outdim=1): ...@@ -5098,14 +5098,21 @@ def flatten(x, outdim=1):
x : theano.tensor.var.TensorVariable x : theano.tensor.var.TensorVariable
the variable that should be reshaped. the variable that should be reshaped.
outdim : int ndim : int
the number of dimensions of the returned variable the number of dimensions of the returned variable
outdim : int
DEPRECATED synonyme for ndim
Returns Returns
------- -------
theano.tensor.var.TensorVariable theano.tensor.var.TensorVariable
the flattend variable with dimensionality of outdim the flattend variable with dimensionality of outdim
""" """
if outdim is None and ndim is None:
outdim = 1
elif outdim is not None and ndim is not None:
raise ValueError("You should only specify outdim or ndim")
elif outdim is None:
outdim = ndim
# Any input variable can be flattened to have outdim of 1, # Any input variable can be flattened to have outdim of 1,
# even if it's a scalar. Otherwise, outdim must be positive # even if it's a scalar. Otherwise, outdim must be positive
# and smaller than x.ndim. # and smaller than x.ndim.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论