Python – tensorflow.matemáticas.erf()

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

erf() se utiliza para calcular la función de error de Gauss de los elementos.

Sintaxis: tensorflow.math.erf(x, nombre)

Parámetros:

  • x: Es el tensor de entrada. Los dtypes permitidos son bfloat16, half, float32, float64.
  • 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 Gauss error
res = tf.math.erf(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.84270079 0.99532227 0.99997791 0.99999998 1.        ], 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 Gauss error
res = tf.math.erf(x = a)
  
# Plotting the graph
plt.plot(a, res, color ='green')
plt.title('tensorflow.math.erf')
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 *