Let's start coding using TensorFlow. We are again going to write basic code that performs matrix operations such as matrix addition, multiplication, scalar multiplication and multiplication with a scalar from 1 to 99. The code is written for demonstrating basic capabilities of TensorFlow, which we have discussed previously.
Here is the code for all these operations:
import tensorflow as tf import time matrix_1 = tf.Variable([[1,2,3],[4,5,6],[7,8,9]],name="mat1") matrix_2 = tf.Variable([[1,2,3],[4,5,6],[7,8,9]],name="mat2") scalar = tf.constant(5) number = tf.Variable(1, name="counter") add_msg = tf.constant("\nResult of matrix addition\n") mul_msg = tf.constant("\nResult of matrix multiplication\n") scalar_mul_msg ...