功能:计算元素x里每一个元素的平方
tf.math.square
(
x,
name=None
)
参数说明:
- x - 一个张量或者是稀疏张量。必须是下列类型之一:half, float32, float64, int32, int64, complex64, complex128.
- name - 操作的名字 (可选参数).
示例如下:
import tensorflow as tf
a = tf.constant([1, 2, 3, 4])
b = tf.square(a)
print(b)
# tf.Tensor([ 1 4 9 16], shape=(4,), dtype=int32)