numpy.around之谜

对于

np.around(boxes.tensor[index].numpy(),decimals=2)

输出正常,即保留小数点后两位的array数组

array([ 393.41, 1516.09,  417.79, 1529.88], dtype=float32)

然而,
对于

np.around(boxes.tensor[index].numpy(),decimals=2).tolist()

则没有经过round,列表中的数字为原来的结果:

[393.4100036621094, 1516.0899658203125, 417.7900085449219, 1529.8800048828125]

即使,赋值处理也是一样:
在这里插入图片描述
这点很奇怪。
只好这样做

bbox = boxes.tensor[index].numpy().tolist()
bbox = [round(i,2) for i in bbox]

可以输出保留两位的结果。

猜你喜欢

转载自blog.csdn.net/qq_44065334/article/details/114154106
今日推荐