TensorFlow argmax 函数示例:寻找张量最大值索引
该代码示例演示了如何使用 TensorFlow 中的 argmax 函数查找张量中最大值的索引。
import tensorflow as tf
import numpy as np
a = tf.constant([[3, 2, 4], [1, 5, 6]])
b = tf.argmax(a)
print(b.numpy())
执行后输出结果为 5,因为 tf.argmax 返回的是张量中最大值的索引。该张量中的最大值为 6,它的索引是 5(从 0 开始计数)。
原文地址: https://www.cveoy.top/t/topic/ovym 著作权归作者所有。请勿转载和采集!