2024-04-25 22:38:37 发布
网友
Tensorflow有两个函数可以将一个数舍入到最接近的整数^{}和^{}。
据我所知,这些函数在做同样的事情,但是它们在不同的类型集上操作,这使得它们中没有一个比另一个更通用(例如,tf.rint可以对{}进行操作,而{}可以对。。。tf.int32?!?)。
tf.rint
tf.int32
所以
tf.round
For tf.round x = tf.constant([0.9, 2.5, 2.3, 1.5, -4.5]) tf.round(x) # [ 1.0, 2.0, 2.0, 2.0, -4.0 ] For tf.rint x = tf.constant([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0]) tf.rint(x) # [-2., -2., -0., 0., 2., 2., 2.]
看看this issue,似乎是两个不同的人碰巧写了这个函数
看看this issue,似乎是两个不同的人碰巧写了这个函数
相关问题 更多 >
编程相关推荐