访问量: 10 次浏览
tensorflow.math.angle() 方法TensorFlow是谷歌设计的开源python库,用于开发机器学习模型和深度学习神经网络。
angle() 是tensorflow数学模块中的方法。该方法用于查找张量的元素的参数。默认情况下,所有元素都被认为是复数(a+bi)。在实数的情况下,复数部分(b)被认为是零。atan2(b,a) 是这个函数计算的参数。
tensorflow.math.angle(
input, name
)
1.input:
它是一个张量。这个张量允许的 dtype 是float, double, complex64, complex128。
2.name:
它是一个可选的参数,定义了操作的名称。
返回:
它返回一个 float32 或 float64 类型的张量。
示例 1:
# importing the library
import tensorflow as tf
# initializing the constant tensor
a = tf.constant([-1.5 + 7.8j, 3 + 5.75j], dtype=tf.complex64)
# calculating the arguments
b = tf.math.angle(a)
# printing the argument tensor
print('Tensor: ',b)
输出:
Tensor: tf.Tensor([1.7607845 1.0899091], shape=(2,), dtype=float32)
示例 2:
在实数的情况下,计算的参数总是零。
# importing the library
import tensorflow as tf
# initializing the constant tensor
a = tf.constant([-1.5, 3 ], dtype=tf.float64)
# calculating the arguments
b = tf.math.angle(a)
# printing the argument tensor
print('Tensor: ',b)
输出:
Tensor: tf.Tensor([0. 0.], shape=(2,), dtype=float64)