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: ```python >>> a = tf.constant([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) >>> a <tf.Tensor: id=4
(x, pattern)
| 2625 | |
| 2626 | @keras_export('keras.backend.permute_dimensions') |
| 2627 | def permute_dimensions(x, pattern): |
| 2628 | """Permutes axes in a tensor. |
| 2629 | |
| 2630 | Arguments: |
| 2631 | x: Tensor or variable. |
| 2632 | pattern: A tuple of |
| 2633 | dimension indices, e.g. `(0, 2, 1)`. |
| 2634 | |
| 2635 | Returns: |
| 2636 | A tensor. |
| 2637 | |
| 2638 | Example: |
| 2639 | ```python |
| 2640 | >>> a = tf.constant([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) |
| 2641 | >>> a |
| 2642 | <tf.Tensor: id=49, shape=(4, 3), dtype=int32, numpy= |
| 2643 | array([[ 1, 2, 3], |
| 2644 | [ 4, 5, 6], |
| 2645 | [ 7, 8, 9], |
| 2646 | [10, 11, 12]], dtype=int32)> |
| 2647 | >>> tf.keras.backend.permute_dimensions(a, pattern=(1, 0)) |
| 2648 | <tf.Tensor: id=52, shape=(3, 4), dtype=int32, numpy= |
| 2649 | array([[ 1, 4, 7, 10], |
| 2650 | [ 2, 5, 8, 11], |
| 2651 | [ 3, 6, 9, 12]], dtype=int32)> |
| 2652 | ``` |
| 2653 | """ |
| 2654 | return array_ops.transpose(x, perm=pattern) |
| 2655 | |
| 2656 | |
| 2657 | @keras_export('keras.backend.resize_images') |
no test coverage detected