当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python tensorflow.math.angle()用法及代码示例


TensorFlow是Google设计的开源python库,用于开发机器学习模型和深度学习神经网络。

angle()是tensorflow数学模块中的方法。此方法用于查找张量的元素明智参数。默认情况下,所有元素都被视为复数(a + bi)。如果是实数,则复数部分(b)被视为零。 atan2(b,a)是此函数计算的参数。

用法:
tensorflow.math.angle(
    input, name
)

Argument:
1. input: It is a tensor. Allowed dtype for this tensor are  float, double, complex64, complex128.
2. name: It is an optional argument that defines the name for the operation.
 
返回:
It returns a tensor of type float32 or float64.

范例1:

Python3

# importing the libraray 
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:

如果是实数,则计算的参数始终为零。

Python3

# importing the libraray 
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)

相关用法


注:本文由纯净天空筛选整理自aman neekhara大神的英文原创作品 Python | tensorflow.math.angle() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。