TensorFlow四舍五入:tf.round函數(shù)

2018-12-28 10:53 更新

tf.round 函數(shù)

round(
    x,
    name=None
)

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

請參閱指南:數(shù)學(xué)函數(shù)>基本數(shù)學(xué)函數(shù)

將張量的值四舍五入為最接近的整數(shù),元素.

均勻的舍入.也被稱為banker四舍五入.如果要根據(jù)當(dāng)前系統(tǒng)舍入模式進(jìn)行舍入,請使用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 ]

參數(shù):

  • x:一個Tensor,類型必須為float32或float64.
  • name:操作的名稱(可選).

返回:

tf.round函數(shù)返回一個與x具有相同的形狀和類型的Tensor.

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號