TensorFlow四舍五入:tf.round函数

2018-12-28 10:53 更新

tf.round 函数

round(
    x,
    name=None
)

定义在:tensorflow/python/ops/math_ops.py.

请参阅指南:数学函数>基本数学函数

将张量的值四舍五入为最接近的整数,元素.

均匀的舍入.也被称为banker四舍五入.如果要根据当前系统舍入模式进行舍入,请使用tf :: cint.例如:

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 ]

参数:

  • x:一个Tensor,类型必须为float32或float64.
  • name:操作的名称(可选).

返回:

tf.round函数返回一个与x具有相同的形状和类型的Tensor.

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号