Link Search Menu Expand Document

Transpose


tensorflow C++ API

tensorflow::ops::Transpose

Shuffle dimensions of x according to a permutation.


Summary

The outputyhas the same rank asx. The shapes ofxandysatisfy:y.shape[i] == x.shape[perm[i]] for i in [0, 1, ..., rank(x) - 1]

For example:

# 'x' is [[1 2 3]
#         [4 5 6]]
# Equivalently
tf.transpose(x, perm=[1,0])==>[[1 4]
                               [2 5]
                               [3 6]]
# 'perm' is more useful for n-dimensional tensors, for n > 2
# 'x' is   [[[1  2  3]
#            [4  5  6]]
#           [[7  8  9]
#            [10 11 12]]]
# Take the transpose of the matrices in dimension-0
tf.transpose(x, perm=[0,2,1])==>[[[1 4]
                                  [2 5]
                                  [3 6]]
                                 [[7 10]
                                  [8 11]
                                  [9 12]]]

Arguments:

  • scope: A Scope object
  • x: A Tensor.
  • perm: A permutation of the dimensions of x.

Returns:


Transpose 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 x: A Tensor.
  • Input perm: A permutation of the dimensions of x.

Output:

  • Output y: Output object of Transpose class object.

Result:

  • std::vector(Tensor) result_y: A transposed Tensor.

Using Method


※ 차원을 바꾸는 역할을 한다. 파이썬에서 쓰는것과 달리 perm에 아무것도 없으면 에러가 난다. x는 차원을 바꿀 tensor를 넣으면 되고, perm은 바꿀 차원의 순서를 index로 넣으면 된다.