W3cubDocs

/TensorFlow 2.3

tf.keras.backend.transpose

View source on GitHub

Transposes a tensor and returns it.

Arguments
x Tensor or variable.
Returns
A tensor.

Examples:

var = tf.keras.backend.variable([[1, 2, 3], [4, 5, 6]])
tf.keras.backend.eval(var)
array([[1.,  2.,  3.],
       [4.,  5.,  6.]], dtype=float32)
var_transposed = tf.keras.backend.transpose(var)
tf.keras.backend.eval(var_transposed)
array([[1.,  4.],
       [2.,  5.],
       [3.,  6.]], dtype=float32)
input = tf.keras.backend.placeholder((2, 3))
input
<tf.Tensor 'Placeholder_...' shape=(2, 3) dtype=float32>
input_transposed = tf.keras.backend.transpose(input)
input_transposed
<tf.Tensor 'Transpose_...' shape=(3, 2) dtype=float32>

© 2020 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/versions/r2.3/api_docs/python/tf/keras/backend/transpose