Python – tensorflow.math.floordiv()

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. 

floordiv() se utiliza para calcular la división inteligente de elementos de x por y y el redondeo del resultado hacia el entero más negativo.

Sintaxis: tensorflow.math.floordiv(x, y, nombre)

Parámetros:

  • x: Es un tensor que tiene valores numéricos reales.
  • y: Es un tensor que tiene valores numéricos reales.
  • name(opcional): Define el nombre de la operación

Devuelve: Devuelve un tensor.

Ejemplo 1:

Python3

# importing the library
import tensorflow as tf
  
# Initializing the input tensor
a = tf.constant([7, 8, 13, 11], dtype = tf.float64)
b = tf.constant([2, 3, 4, 5],  dtype = tf.float64)
  
# Printing the input tensor
print('a: ', a)
print('b: ', b)
  
# Calculating style division
res = tf.math.floordiv(x = a, y = b)
  
# Printing the result
print('Result: ', res)

Producción:

a:  tf.Tensor([ 7.  8. 13. 11.], shape=(4, ), dtype=float64)
b:  tf.Tensor([2. 3. 4. 5.], shape=(4, ), dtype=float64)
Result:  tf.Tensor([3. 2. 3. 2.], shape=(4, ), dtype=float64)


Ejemplo 2: En este ejemplo uno de los valores en segundo tensor se toma 0.

Python3

# Importing the libraray
import tensorflow as tf
  
# Initializing the input tensor
a = tf.constant([7, 8, 13, 11], dtype = tf.float64)
b = tf.constant([2, 3, 4, 0],  dtype = tf.float64)
  
# Printing the input tensor
print('a: ', a)
print('b: ', b)
  
# Calculating style division
res = tf.math.floordiv(x = a, y = b)
  
# Printing the result
print('Result: ', res)

Producción:

a:  tf.Tensor([ 7.  8. 13. 11.], shape=(4, ), dtype=float64)
b:  tf.Tensor([2. 3. 4. 0.], shape=(4, ), dtype=float64)
Result:  tf.Tensor([ 3.  2.  3. inf], shape=(4, ), 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 *