IKH

Linear Algebra with Tensorflow

In this segment, you will learn about the functions that can help you perform linear algebra tasks. In the next video, Avishek will walk you through some commonly used functions of the linear algebra module on TensorFlow.

So, in this video, you learnt about TensorFlow’s linalg module. Let’s summarise the concepts covered in the video:

  1. The linalg module in the TensorFlow library has all the necessary functions for processing matrices. You can visit this page to read about the functions available.
  2. Many matrix operations require shape compatibility. For instance, in the case of matrix multiplication, the number of columns in the first matrix needs to be equal to the number of rows in the second. Conditions such as these need to be met while performing the respective operations on tensors. If such conditions are not met, then TensorFlow will throw an error.
  3. It is possible that some linear operations are not defined. For example, all the matrices cannot be inverted. In such cases as well, TensorFlow will throw an error. So, to perform a matrix operation, that operation should be mathematically possible. For example, it is not possible to calculate the inverse of a matrix with the determinant 0. It will not be possible in TensorFlow either.
  4. TensorFlow uses numerical algorithms for carrying out matrix operations. So, it is important to have a tensor that is of the float data type.

Let’s try to apply this knowledge to a problem. We need to solve this system of linear equations using TensorFlow.

x + y + z + w = 13

2x + 3y − w = −1

−3x + 4y + z + 2w = 10

x + 2y − z + w = 1

The theory behind solving the system of linear equations is to implement the matrix representation of linear equations, which is represented in this way.

W.X=Y

where W is the coefficient matrix, X denotes the variables and Y is the output matrix. On solving for X, you will obtain this. 


X=YW−1

In the upcoming video, Avishek will solve this equation for you.

Based on what was covered in this video, try solving this question.

In this session, you learnt how to perform linear algebra with TensorFlow. The content that we have covered till now is sufficient to proceed with the implementation of a neural network with TensorFlow. However, you can explore the optional segment that gives details about the different aspects of TensorFlow related to smarter ways to compute such as reshaping and broadcasting, building your own custom training algorithm,  gaining a deeper understanding of gradients, minimising any given function and gaining an understanding of the language architecture of TensorFlow. 

In the next segment, you will go through an implementation of a neural network to make house price predictions using TensorFlow.

Report an error