提交 8f1242f7 authored 作者: Seon-Wook Park's avatar Seon-Wook Park

Fix comments for compress

上级 f1ae9055
......@@ -514,15 +514,14 @@ def squeeze(x):
def compress(condition, x, axis=None, out=None):
"""Return selected slices of an array along given axis.
It returns the input array, but with the
broadcastable dimensions removed. This is
always `x` itself or a view into `x`.
Wrapping of numpy.compress
It returns the input tensor, but with selected slices along a given axis
retained. If no axis is provided, the tensor is flattened
Corresponds to numpy.compress
:param x: 1 dimension, bools
:param x: Input data, tensor variable
:param condition: array of the same shape as x with corresponding weights.
Optional.
:param condition: 1 dimensional array of non-zero and zero values
corresponding to indices of slices along a selected axis
:return: `x` with selected slices
......@@ -530,6 +529,7 @@ def compress(condition, x, axis=None, out=None):
"""
# This is done to keep the same function signature then NumPy.
assert out is None
indices = theano.tensor.basic.flatnonzero(condition)
return x.take(indices, axis=axis)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论