Python ``tensorflow.math.angle()`` 复数相位角计算方法与实例


发布日期 : 2019-11-26 13:34:21 UTC

访问量: 10 次浏览

Python 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:
它是一个可选的参数,定义了操作的名称。

返回:

它返回一个 float32float64 类型的张量。

示例 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)