如何在 3d 数组中使用 argmax tensorflow 函数?
How to use argmax tensorflow function in 3d array?
我想知道如何在 3D 数组中使用 tf.argmax
。
我的输入数据是这样的:
[[[0, -1, 5, 2, 1], [2, 2, 3, 2, 5], [6, 1, 2, 4, -1]],
[[-1, -2, 3, 2, 1], [0, 3, 2, 7, -1], [-1, 5, 2, 1, 3]]]
我想通过这样的输入数据获得 argmax 的输出:
[[2, 4, 0], [2, 3, 1]]
而且我想以这种格式使用 softmax_cross_entropy_with_logits
函数。
我应该如何使用 tf.nn.softmax_cross_entropy_with_logits
函数以及 tf.equal(tf.argmax)
和 tf.reduce_mean(tf.cast)
?
您可以使用 tf.argmax
和 axis=3
a = tf.constant([[[0, -1, 5, 2, 1], [2, 2, 3, 2, 5], [6, 1, 2, 4, -1]],
[[-1, -2, 3, 2, 1], [0, 3, 2, 7, -1], [-1, 5, 2, 1, 3]]])
b = tf.argmax(a, axis=2)
我想知道如何在 3D 数组中使用 tf.argmax
。
我的输入数据是这样的:
[[[0, -1, 5, 2, 1], [2, 2, 3, 2, 5], [6, 1, 2, 4, -1]],
[[-1, -2, 3, 2, 1], [0, 3, 2, 7, -1], [-1, 5, 2, 1, 3]]]
我想通过这样的输入数据获得 argmax 的输出:
[[2, 4, 0], [2, 3, 1]]
而且我想以这种格式使用 softmax_cross_entropy_with_logits
函数。
我应该如何使用 tf.nn.softmax_cross_entropy_with_logits
函数以及 tf.equal(tf.argmax)
和 tf.reduce_mean(tf.cast)
?
您可以使用 tf.argmax
和 axis=3
a = tf.constant([[[0, -1, 5, 2, 1], [2, 2, 3, 2, 5], [6, 1, 2, 4, -1]],
[[-1, -2, 3, 2, 1], [0, 3, 2, 7, -1], [-1, 5, 2, 1, 3]]])
b = tf.argmax(a, axis=2)