# TensorFlow - Mathematical Foundations

## TensorFlow - Mathematical Foundations - It is important to understand mathematical concepts needed for TensorFlow before creating the basic application in TensorFlow. Mathematics is considered as the It is important to understand mathematical concepts needed for TensorFlow before creating the basic application in TensorFlow. Mathematics is considered as the heart of any machine learning algorithm. It is with the help of core concepts of Mathematics, a solution for specific machine learning algorithm is defined.

## Vector

An array of numbers, which is either continuous or discrete, is defined as a vector. Machine learning algorithms deal with fixed length vectors for better output generation.

Machine learning algorithms deal with multidimensional data so vectors play a crucial role. The pictorial representation of vector model is as shown below − ### Scalar

Scalar can be defined as a one-dimensional vector. Scalars are those, which include the only magnitude and no direction. With scalars, we are only concerned with the magnitude.

Examples of scalar include weight and height parameters of children.

### Matrix

Matrix can be defined as multi-dimensional arrays, which are arranged in the format of rows and columns. The size of matrix is defined by row length and column length. Following figure shows the representation of any specified matrix. Consider the matrix with “m” rows and “n” columns as mentioned above, the matrix representation will be specified as “m*n matrix” which defined the length of matrix as well.

## Mathematical Computations

In this section, we will learn about the different Mathematical Computations in TensorFlow.

The addition of two or more matrices is possible if the matrices are of the same dimension. The addition implies each element as per the given position.

Consider the following example to understand how addition of matrices works − ### Subtraction of matrices

The subtraction of matrices operates in similar fashion like the addition of two matrices. The user can subtract two matrices provided the dimensions are equal. ### Multiplication of matrices

For two matrices A m*n and B p*q to be multipliable, n should be equal to p. The resulting matrix is −

C m*q ### Transpose of matrix

The transpose of a matrix A, m*n is generally represented by AT (transpose) n*m and is obtained by transposing the column vectors as row vectors. ### Dot product of vectors

Any vector of dimension n can be represented as a matrix v = R^n*1. The dot product of two vectors is the sum of the product of corresponding components − Components along the same dimension and can be expressed as The example of dot product of vectors is mentioned below − 