tf.matrix_transpose
tf.matrix_transpose
tf.matrix_transpose
matrix_transpose( a, name='matrix_transpose' )
Defined in tensorflow/python/ops/array_ops.py
.
See the guide: Math > Matrix Math Functions
Transposes last two dimensions of tensor a
.
For example:
# Matrix with no batch dimension. # 'x' is [[1 2 3] # [4 5 6]] tf.matrix_transpose(x) ==> [[1 4] [2 5] [3 6]] # Matrix with two batch dimensions. # x.shape is [1, 2, 3, 4] # tf.matrix_transpose(x) is shape [1, 2, 4, 3]
Note that tf.matmul
provides kwargs allowing for transpose of arguments. This is done with minimal cost, and is preferable to using this function. E.g.
# Good! Transpose is taken at minimal additional cost. tf.matmul(matrix, b, transpose_b=True) # Inefficient! tf.matmul(matrix, tf.matrix_transpose(b))
Args:
-
a
: ATensor
withrank >= 2
. -
name
: A name for the operation (optional).
Returns:
A transposed batch matrix Tensor
.
Raises:
-
ValueError
: Ifa
is determined statically to haverank < 2
.
© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/matrix_transpose