Python – tensorflow.math.sin()

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.
sin() se usa para encontrar el elemento seno sabio de x.

Sintaxis: tf.math.sin(x, nombre)

Parámetros: 

  • x: Es el tensor de entrada. Los tipos permitidos para este tensor son bfloat16, half, float32, float64, complex64, complex128.
  • name(opcional): Define el nombre de la operación.
     

Devoluciones:  Devuelve un tensor del mismo tipo que x.
 

Ejemplo 1:

Python3

# Importing the library
import tensorflow as tf
  
# Initializing the input tensor
a = tf.constant([1, 2, 3, 4, 5], dtype = tf.float64)
  
# Printing the input tensor
print('Input: ', a)
  
# Calculating tangent
res = tf.math.sin(x = a)
  
# Printing the result
print('Result: ', res)

Producción:

Input:  tf.Tensor([1. 2. 3. 4. 5.], shape=(5, ), dtype=float64)
Result:  tf.Tensor([ 0.84147098  0.90929743  0.14112001 -0.7568025  -0.95892427], shape=(5, ), dtype=float64)


Ejemplo 2: Visualización

Python3

# importing the library
import tensorflow as tf
import matplotlib.pyplot as plt
  
# Initializing the input tensor
a = tf.constant([1, 2, 3, 4, 5], dtype = tf.float64)
  
# Calculating tangent
res = tf.math.sin(x = a)
  
# Plotting the graph
plt.plot(a, res, color ='green')
plt.title('tensorflow.math.sin')
plt.xlabel('Input')
plt.ylabel('Result')
plt.show()

Producción:

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 *