[PYTHON] Tensorflow-API: tf.reverse

https://www.tensorflow.org/api_docs/python/tf/reverse

reverse(
    tensor,
    axis,
    name=None
)

Anwendungsbeispiel

import tensorflow as tf

# Definieren Sie einen dreidimensionalen Tensor
x = tf.constant([[[1, 2, 3], [4, 5, 6], [7, 8, 9]],
                [[11, 12, 13], [14, 15, 16], [17, 18, 19]]])

sess = tf.Session()
x_reverse_0 = tf.reverse(x, [0])
x_reverse_1 = tf.reverse(x, [1])
x_reverse_2 = tf.reverse(x, [2])
x_reverse_0_1 = tf.reverse(x, [0, 1])
x_reverse_0_1_2 = tf.reverse(x, [0, 1, 2])

# Überprüfen Sie das Ergebnis
print(str(sess.run(x)) + '\n')

print("tf.reverse(x, [0]):")
print(str(sess.run(x_reverse_0)) + '\n')

print("tf.reverse(x, [1]):")
print(str(sess.run(x_reverse_1)) + '\n')

print("tf.reverse(x, [2]):")
print(str(sess.run(x_reverse_2)) + '\n')

print("tf.reverse(x, [0, 1]):")
print(str(sess.run(x_reverse_0_1)) + '\n')

print("tf.reverse(x, [0, 1, 2]):")
print(str(sess.run(x_reverse_0_1_2)) + '\n')
[[[ 1  2  3]
 [ 4  5  6]
 [ 7  8  9]]

[[11 12 13]
 [14 15 16]
 [17 18 19]]]

tf.reverse(x, [0]):
[[[11 12 13]
 [14 15 16]
 [17 18 19]]

[[ 1  2  3]
 [ 4  5  6]
 [ 7  8  9]]]

tf.reverse(x, [1]):
[[[ 7  8  9]
 [ 4  5  6]
 [ 1  2  3]]

[[17 18 19]
 [14 15 16]
 [11 12 13]]]

tf.reverse(x, [2]):
[[[ 3  2  1]
 [ 6  5  4]
 [ 9  8  7]]

[[13 12 11]
 [16 15 14]
 [19 18 17]]]

tf.reverse(x, [0, 1]):
[[[17 18 19]
 [14 15 16]
 [11 12 13]]

[[ 7  8  9]
 [ 4  5  6]
 [ 1  2  3]]]

tf.reverse(x, [0, 1, 2]):
[[[19 18 17]
 [16 15 14]
 [13 12 11]]

[[ 9  8  7]
 [ 6  5  4]
 [ 3  2  1]]]

Recommended Posts

Tensorflow-API: tf.reverse
Tensorflow-API: tf.truncated_normal
Tensorflow API: FLAGGEN
TensorFlow API-Memo
[TF] Informationen zur Tensorflow-API
TensorFlow API-Memo (Python)
Logoerkennung mit der TensorFlow-Objekterkennungs-API
Tensorflow Glossar
tensorflow mnist_deep.py
TensorFlow Tutorial Tutorial
Finden Sie eine Polynomnäherung mit der Low-Level-API von TensorFlow 2.x.