Link Search Menu Expand Document

Squeeze


tensorflow C++ API

tensorflow::ops::Squeeze

Removes dimensions of size 1 from the shape of a tensor.


Summary

Given a tensorinput, 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 specifyingsqueeze_dims.

For example:

``` ‘t’ is a tensor of shape [1, 2, 1, 3, 1, 1]

shape(squeeze(t)) ==> [2, 3] ```

Or, to remove specific size 1 dimensions:

``` ‘t’ is a tensor of shape [1, 2, 1, 3, 1, 1]

shape(squeeze(t, [2, 4])) ==> [1, 2, 3, 1] ```

Arguments:

  • scope: A Scope object
  • input: The input to squeeze.

Optional attributes (seeAttrs):

  • squeeze_dims: If specified, only squeezes the dimensions listed. The dimension index starts at 0. It is an error to squeeze a dimension that is not 1. Must be in the range [-rank(input), rank(input)).

Returns:

  • Output: Contains the same data as input, but has one or more dimensions of size 1 removed.

Squeeze block

Source link :https://github.com/EXPNUNI/enuSpaceTensorflow/blob/master/enuSpaceTensorflow/tf_array_ops.cpp

Argument:

  • Scope scope : A Scope object (A scope is generated automatically each page. A scope is not connected.)
  • Input input: The input to squeeze.
  • Squeeze::Attrs attrs:
    • squeeze_dims: If specified, only squeezes the dimensions listed. The dimension index starts at 0. It is an error to squeeze a dimension that is not 1. Must be in the range [-rank(input), rank(input)).

Output:

  • Output output: Output object of Squeeze class object.

Result:

  • std::vector(Tensor) result_output: The output tensor.

Using Method

※ input에 들어온 tensor의 shape중에서 각 차원의 사이즈가 1인 것들을 제거하는 기능을 한다. attrs의 squeeze_dims는 size가 1인 차원을 선택해서 제거할 수 있도록 해준다. ( squeeze_dims에 들어가는 값은 index 값이다. ex: 1-D를 선택 하려면 0, 4-D를 선택하려면 3을 입력하면 된다.)