Do you want to start learning Machine Learning and keep hearing buzzwords related to Linear Algebra? Vector, matrix, tensor? Those are basic Linear Algebra Definitions.

Perhaps you want to learn Linear Algebra for Machine Learning and looking for a place to hit first?

In one of the previous articles, we discussed the importance of Linear Algebra in Machine Learning. Here, we introduce some of the most commonly used Linear Algebra definitions.

This article aims to accomplish the following:

  • Provide the basic definitions in Linear Algebra that we hear every day while dealing with Machine Learning.
  • Describe the connection between those basic concepts.
  • Demonstration of the commonly used notations.

If you already know Linear Algebra and/or familiar with basic definitions, you may still find some aspects of this article useful, such as the representation of “the commonly used notations.”

Let’s get started!

Scalar and Vector

By using mathematical definition, a scalar is “an element of a field, which is used to define a vector space, usually the field of real numbers.” Simply speaking, a scalar is just a number. We usually denote a scalar with a lower case symbol, such as a.

It is worth to have a comparison between scalars and vectors. You are familiar with measures such as the velocity of a moving car and the direction of moving, which have both quantity and direction. Such elements are called vector as opposed to scalars, which have magnitude only. We denote vectors with bold symbols such as \boldsymbol{a}.

Linear Algebra Definitions
The red arrow v is the vector and a and b are scalars denoting the magnitudes of v in horizontal and vertical directions.

Subscripts usually denote the elements of the vector. For example the second element of the vector \boldsymbol{v} is denoted as \boldsymbol{v_2}. In general, we show a k-dimensional vector as an array of elements:

    \[\boldsymbol{v} = \begin{pmatrix} v_1\\  v_2\\  …\\  v_{k-1}\\  v_k \end{pmatrix}\]

Matrix

In mathematics, a matrix is a rectangular array of elements, such as numbers organized in rows and columns. Usually, the matrices are denoted with bold uppercase, such as \boldsymbol{M}. An example of a matrix is below:

    \[\boldsymbol{A} = \begin{bmatrix} 1 & -1 &3 \\  4& 11 & -0.2 \end{bmatrix}\]

We denote the matrix elements with subscripts. In the matrix \boldsymbol{M}, the element in i^{th} row and j^{th} column is denoted as \boldsymbol{M}_{i,j}. So you can easily say for the example above, \boldsymbol{M}_{1,2}=-1 and \boldsymbol{M}_{2,3}=-0.2.

Another important notation is when we desire to refer a row or a column as a whole, i.e., all elements in that particular row/column. In this case, we use “:” sign in the subscript. For example, assume we want to refer to all elements of i^{th} row for matrix \boldsymbol{M}. We denote that row with \boldsymbol{M}_{i,:}. For matrix \boldsymbol{A}, \boldsymbol{A}_{1,:} is as below:

    \[\boldsymbol{A}_{1,:} = \begin{bmatrix} 1 & -1 &3 \end{bmatrix}\]

Tensor

We usually represent data in machine learning, numerically. Tensors are used for such numerical representation. A tensor is simply a container that holds data in N-dimensional space. A Tensor can host and represent multiple matrices. An example is shown below:

    \[\begin{bmatrix} \begin{bmatrix} 10 & 3 &3.1 \\   6 & 12 & -0.2 \end{bmatrix} & \begin{bmatrix} 1.0 & -1 &3 \\   4& 11 & -2 \end{bmatrix}\\ \begin{bmatrix} 1 & -2 &7 \\   4.& 1.1 & 81.1 \end{bmatrix}& \begin{bmatrix} 1.1 & -2 &-2 \\  4& 4 & -5 \end{bmatrix} \end{bmatrix}\]

You can consider a simple 3D tensor as the data cube depicted below:

Linear Algebra Definitions

In this tensor, each color represents a matrix and the concatenation of the matrices, form the tensor.

Conclusion

In this post, we described some of the most commonly used Linear Algebra definitions in Machine Learning. Scalar, vector, matrix, and tensor are what you hear the most. It was crucial to address them before we proceed to explain other concepts in Linear Algebra.

P.S. Please share with me your thoughts by commenting below. I might be wrong in what I say, and I love to know when I am wrong. Furthermore, your questions might be my questions, as well. It’s always good to become better even if being the best is impossible in our belief system. So let’s help each other to become better.

0

Sina Torfi

Currently, as a CS Ph.D. student, I'm a research assistant at Virginia Tech. My research is mainly about Machine Learning & Deep Learning and their applications in Computer Vision and NLP. I'm interested in developing software packages and open-source projects.

Leave a Reply

avatar
  Subscribe  
Notify of
Tweet
Share
Pin
Share