Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Álgebra Linear | Tensor Operations and Execution
Introdução ao TensorFlow

bookÁlgebra Linear

1234567891011121314
import tensorflow as tf # Create two matrices matrix1 = tf.constant([[1, 2], [3, 4], [2, 1]]) matrix2 = tf.constant([[2, 0, 2, 5], [2, 2, 1, 3]]) # Multiply the matrices product1 = tf.matmul(matrix1, matrix2) product2 = matrix1 @ matrix2 # Display tensors print(product1) print('-' * 50) print(product2)
copy
Note
Nota
123456789101112131415
import tensorflow as tf # Create 2x2 matrix matrix = tf.constant([[1., 2.], [3., 4.]]) # Compute the inverse of a matrix inverse_mat = tf.linalg.inv(matrix) # Check the result identity = matrix @ inverse_mat # Display tensors print(inverse_mat) print('-' * 50) print(identity)
copy
Note
Nota
123456789101112
import tensorflow as tf # Create a matrix 3x2 matrix = tf.constant([[1, 2], [3, 4], [2, 1]]) # Get the transpose of a matrix transposed = tf.transpose(matrix) # Display tensors print(matrix) print('-' * 40) print(transposed)
copy
1234567891011121314
import tensorflow as tf # Create two vectors matrix1 = tf.constant([1, 2, 3, 4]) matrix2 = tf.constant([2, 0, 2, 5]) # Compute the dot product of two tensors dot_product_axes1 = tf.tensordot(matrix1, matrix2, axes=1) dot_product_axes0 = tf.tensordot(matrix1, matrix2, axes=0) # Display tensors print(dot_product_axes1) print('-' * 40) print(dot_product_axes0)
copy
Note
Nota
Tarefa

Swipe to start coding

Solução

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 2
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Suggested prompts:

Can you explain the difference between tf.matmul() and the @ operator?

How do I know when to use tf.tensordot() instead of tf.matmul()?

Can you provide more examples of matrix operations in TensorFlow?

close

bookÁlgebra Linear

Deslize para mostrar o menu

1234567891011121314
import tensorflow as tf # Create two matrices matrix1 = tf.constant([[1, 2], [3, 4], [2, 1]]) matrix2 = tf.constant([[2, 0, 2, 5], [2, 2, 1, 3]]) # Multiply the matrices product1 = tf.matmul(matrix1, matrix2) product2 = matrix1 @ matrix2 # Display tensors print(product1) print('-' * 50) print(product2)
copy
Note
Nota
123456789101112131415
import tensorflow as tf # Create 2x2 matrix matrix = tf.constant([[1., 2.], [3., 4.]]) # Compute the inverse of a matrix inverse_mat = tf.linalg.inv(matrix) # Check the result identity = matrix @ inverse_mat # Display tensors print(inverse_mat) print('-' * 50) print(identity)
copy
Note
Nota
123456789101112
import tensorflow as tf # Create a matrix 3x2 matrix = tf.constant([[1, 2], [3, 4], [2, 1]]) # Get the transpose of a matrix transposed = tf.transpose(matrix) # Display tensors print(matrix) print('-' * 40) print(transposed)
copy
1234567891011121314
import tensorflow as tf # Create two vectors matrix1 = tf.constant([1, 2, 3, 4]) matrix2 = tf.constant([2, 0, 2, 5]) # Compute the dot product of two tensors dot_product_axes1 = tf.tensordot(matrix1, matrix2, axes=1) dot_product_axes0 = tf.tensordot(matrix1, matrix2, axes=0) # Display tensors print(dot_product_axes1) print('-' * 40) print(dot_product_axes0)
copy
Note
Nota
Tarefa

Swipe to start coding

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 2
single

single

some-alt