Python | método tensorflow.math.angle()

TensorFlow es una biblioteca de Python de código abierto diseñada por Google para desarrollar modelos de aprendizaje automático y redes neuronales de aprendizaje profundo.

angle() es un método en el módulo matemático de tensorflow. Este método se utiliza para encontrar el argumento de elemento sabio de un tensor. Por defecto todos los elementos se consideran como número complejo (a+bi). En el caso del complejo de números reales, la parte (b) se considera como cero. atan2(b,a) es el argumento calculado por esta función.

Syntax:
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.
 
Return:
It returns a tensor of type float32 or float64.

Ejemplo 1:

Python3

# 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)

Producción:

Tensor:  tf.Tensor([1.7607845 1.0899091], shape=(2,), dtype=float32)

Ejemplo 2:

En el caso de números reales, el argumento calculado siempre es cero.

Python3

# 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)

Producción:

Tensor:  tf.Tensor([0. 0.], shape=(2,), dtype=float64)

Publicación traducida automáticamente

Artículo escrito por aman neekhara y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *