用法
__abs__(
name=None
)參數
-
xTensor或SparseTensor類型為float16、float32、float64、int32、int64、complex64或complex128。 -
name操作的名稱(可選)。
返回
-
A
Tensor或者SparseTensor具有相同的大小、類型和稀疏性x,具有絕對值。注意,對於complex64或者complex128輸入,返回Tensor將是類型float32或者float64, 分別。如果
x是SparseTensor,則返回SparseTensor(x.indices, tf.math.abs(x.values, ...), x.dense_shape)
計算張量的絕對值。
給定整數或浮點值的張量,此操作返回相同類型的張量,其中每個元素包含輸入中相應元素的絕對值。
給定複數張量 x,此操作返回類型為 float32 或 float64 的張量,它是 x 中每個元素的絕對值。對於複數 ,其絕對值計算為 。
例如:
# real number
x = tf.constant([-2.25, 3.25])
tf.abs(x)
<tf.Tensor: shape=(2,), dtype=float32,
numpy=array([2.25, 3.25], dtype=float32)>
# complex number
x = tf.constant([[-2.25 + 4.75j], [-3.25 + 5.75j]])
tf.abs(x)
<tf.Tensor: shape=(2, 1), dtype=float64, numpy=
array([[5.25594901],
[6.60492241]])>
相關用法
- Python tf.RaggedTensor.__add__用法及代碼示例
- Python tf.RaggedTensor.__and__用法及代碼示例
- Python tf.RaggedTensor.__rmul__用法及代碼示例
- Python tf.RaggedTensor.__radd__用法及代碼示例
- Python tf.RaggedTensor.__pow__用法及代碼示例
- Python tf.RaggedTensor.__rand__用法及代碼示例
- Python tf.RaggedTensor.__xor__用法及代碼示例
- Python tf.RaggedTensor.__gt__用法及代碼示例
- Python tf.RaggedTensor.__getitem__用法及代碼示例
- Python tf.RaggedTensor.__rpow__用法及代碼示例
- Python tf.RaggedTensor.__rxor__用法及代碼示例
- Python tf.RaggedTensor.__ror__用法及代碼示例
- Python tf.RaggedTensor.__rsub__用法及代碼示例
- Python tf.RaggedTensor.__sub__用法及代碼示例
- Python tf.RaggedTensor.__lt__用法及代碼示例
- Python tf.RaggedTensor.__or__用法及代碼示例
- Python tf.RaggedTensor.__ge__用法及代碼示例
- Python tf.RaggedTensor.__invert__用法及代碼示例
- Python tf.RaggedTensor.__le__用法及代碼示例
- Python tf.RaggedTensor.__mul__用法及代碼示例
- Python tf.RaggedTensor.row_lengths用法及代碼示例
- Python tf.RaggedTensor.from_value_rowids用法及代碼示例
- Python tf.RaggedTensor.from_uniform_row_length用法及代碼示例
- Python tf.RaggedTensor.numpy用法及代碼示例
- Python tf.RaggedTensor.get_shape用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.RaggedTensor.__abs__。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
