所以我想要argmax y0,我在numpy和tensorflow 2中测试了它,结果是不同的。 不知道为什么。你知道吗
maxy0 = np.amax(y0)
e0 = np.exp(y0 - maxy0)
p0 = e0 / np.sum(e0)
y0 = np.log(1e-20 + p0)
print(y0)
[[-46.0517 -46.0517 -46.0517 ... -46.0517 -46.0517 -46.0517]]
np.argsort(-y0)
array([[ 11, 0, 26664, ..., 13337, 13330, 40001]])
tf.argsort(-y0)
array([[ 11, 0, 1, ..., 39999, 40000, 40001]], dtype=int32)
为什么它们不同?你知道吗
尝试将stable参数更改为True,因为默认情况下,它是Falsetf.argsort文件. 请参考https://www.tensorflow.org/api_docs/python/tf/argsort
相关问题 更多 >
编程相关推荐