chainer.functions.squeeze¶
-
chainer.functions.
squeeze
(x, axis=None)[source]¶ Remove demensions of size one from the shape of a ndarray.
Parameters: - x (
Variable
ornumpy.ndarray
orcupy.ndarray
) – Input variable. A \((s_1, s_2, ..., s_N)\) -shaped float array. - axis (None or int or tuple of ints) – A subset of the single-dimensional
entries in the shape to remove. If
None
is supplied, all of them are removed. The dimension index starts at zero. If an axis with dimension greater than one is selected, an error is raised.
Returns: Variable whose dimensions of size 1 are removed.
Return type: Example
>>> x = np.array([[[[0, 1, 2]]], [[[3, 4, 5]]]], 'f') >>> x.shape (2, 1, 1, 3) >>> y = F.squeeze(x) >>> y.shape (2, 3) >>> y.data array([[ 0., 1., 2.], [ 3., 4., 5.]], dtype=float32) >>> y = F.squeeze(x, axis=1) >>> y.shape (2, 1, 3) >>> y.data array([[[ 0., 1., 2.]], [[ 3., 4., 5.]]], dtype=float32) >>> y = F.squeeze(x, axis=(1, 2)) >>> y.shape (2, 3) >>> y.data array([[ 0., 1., 2.], [ 3., 4., 5.]], dtype=float32)
- x (