Álgebra Linear
1234567891011121314import 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)
Nota
123456789101112131415import 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)
Nota
123456789101112import 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)
1234567891011121314import 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)
Nota
Tarefa
Swipe to start coding
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 2. Capítulo 2
single
Pergunte à IA
Pergunte à IA
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?
Incrível!
Completion taxa melhorada para 6.25
Álgebra Linear
Deslize para mostrar o menu
1234567891011121314import 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)
Nota
123456789101112131415import 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)
Nota
123456789101112import 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)
1234567891011121314import 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)
Nota
Tarefa
Swipe to start coding
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 2. Capítulo 2
single