MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / squeeze

Function squeeze

tensorflow/python/ops/array_ops.py:3605–3653  ·  view source on GitHub ↗

Removes dimensions of size 1 from the shape of a tensor. Given a tensor `input`, this operation returns a tensor of the same type with all dimensions of size 1 removed. If you don't want to remove all size 1 dimensions, you can remove specific size 1 dimensions by specifying `axis`. For

(input, axis=None, name=None, squeeze_dims=None)

Source from the content-addressed store, hash-verified

3603@deprecation.deprecated_args(None, "Use the `axis` argument instead",
3604 "squeeze_dims")
3605def squeeze(input, axis=None, name=None, squeeze_dims=None):
3606 # pylint: disable=redefined-builtin
3607 """Removes dimensions of size 1 from the shape of a tensor.
3608
3609 Given a tensor `input`, this operation returns a tensor of the same type with
3610 all dimensions of size 1 removed. If you don't want to remove all size 1
3611 dimensions, you can remove specific size 1 dimensions by specifying
3612 `axis`.
3613
3614 For example:
3615
3616 ```python
3617 # 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
3618 tf.shape(tf.squeeze(t)) # [2, 3]
3619 ```
3620
3621 Or, to remove specific size 1 dimensions:
3622
3623 ```python
3624 # 't' is a tensor of shape [1, 2, 1, 3, 1, 1]
3625 tf.shape(tf.squeeze(t, [2, 4])) # [1, 2, 3, 1]
3626 ```
3627
3628 Note: if `input` is a `tf.RaggedTensor`, then this operation takes `O(N)`
3629 time, where `N` is the number of elements in the squeezed dimensions.
3630
3631 Args:
3632 input: A `Tensor`. The `input` to squeeze.
3633 axis: An optional list of `ints`. Defaults to `[]`. If specified, only
3634 squeezes the dimensions listed. The dimension index starts at 0. It is an
3635 error to squeeze a dimension that is not 1. Must be in the range
3636 `[-rank(input), rank(input))`.
3637 Must be specified if `input` is a `RaggedTensor`.
3638 name: A name for the operation (optional).
3639 squeeze_dims: Deprecated keyword argument that is now axis.
3640
3641 Returns:
3642 A `Tensor`. Has the same type as `input`.
3643 Contains the same data as `input`, but has one or more dimensions of
3644 size 1 removed.
3645
3646 Raises:
3647 ValueError: When both `squeeze_dims` and `axis` are specified.
3648 """
3649 axis = deprecation.deprecated_argument_lookup("axis", axis, "squeeze_dims",
3650 squeeze_dims)
3651 if np.isscalar(axis):
3652 axis = [axis]
3653 return gen_array_ops.squeeze(input, axis, name)
3654
3655
3656@tf_export("squeeze", v1=[])

Callers 3

_apply_mask_1dFunction · 0.70
squeeze_v2Function · 0.70
batch_gather_ndFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected