tf.argsort文件以及np.argsort命令给出了不同的结果

2024-09-30 01:23:12 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我想要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)

为什么它们不同?你知道吗


Tags: numpylogtftensorflownparraysumprint

热门问题