W3cubDocs

/TensorFlow 1.15

tf.keras.backend.permute_dimensions

View source on GitHub

Permutes axes in a tensor.

Arguments
x Tensor or variable.
pattern A tuple of dimension indices, e.g. (0, 2, 1).
Returns
A tensor.

Example:

a = tf.constant([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])
a
<tf.Tensor: id=49, shape=(4, 3), dtype=int32, numpy=
array([[ 1,  2,  3],
       [ 4,  5,  6],
       [ 7,  8,  9],
       [10, 11, 12]], dtype=int32)>
tf.keras.backend.permute_dimensions(a, pattern=(1, 0))
<tf.Tensor: id=52, shape=(3, 4), dtype=int32, numpy=
array([[ 1,  4,  7, 10],
       [ 2,  5,  8, 11],
       [ 3,  6,  9, 12]], dtype=int32)>

© 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/r1.15/api_docs/python/tf/keras/backend/permute_dimensions