Vector and Matrix operationsVector and Matrix operations
1. Jinho Seo
Network Science Lab
Dept. of CSIE
The Catholic University of Korea
E-mail: kkinho04@catholic.ac.kr
2. 1
Vectors and Matrices and Tensors
Tensors
Sample and Feature
The operation of vectors and matrices
Application
Discussion
3. 2
1. Vectors and Matrices and tensors
A vector is a quantity with size and direction. It is a shape listed with numbers and represented by a one-
dimensional array or list in Python.
A matrix, on the other hand, is a structure that has two-dimensional shapes with rows and columns.
In Python, we represent it as a two-dimensional array.
The horizontal lines are called rows and the vertical lines are called columns.
From three dimensions onwards, we call them tensors. Tensor is represented by more than three-dimensional
array in Python.
4. 3
2. Tensors
Artificial neural networks solve complex models of operations primarily through matrix operations.
However, matrix operations here do not just mean matrix operations through two-dimensional arrays.
As the input and output of machine learning become more complex, an understanding of three-
dimensional tensors is essential.
For example, in RNN, one of the artificial neural network models, it is not easy to understand without
understanding the concept of three-dimensional tensors.
Let me explain the tensor using Numpy.
5. 4
2. Tensors
Scalar refers to data consisting of one real value. This is called a zero-dimensional tensor.
Dimension is called a zero-dimensional tensor in English.
1) Zero-dimensional tensor (Scalar)
Note the value that comes out when ndim of Numpy is output. We call the value that comes
out when ndim is output the number of axes or the dimension of the tensor. Be sure to
remember these two terms.
6. 5
2. Tensors
The arrangement of numbers is called a vector. A vector is a one-dimensional tensor.
It should be noted that the term dimension is also used in vectors, but the dimension of the vector
and the dimension of the tensor are different concepts.
The example below is a four-dimensional vector, but it is a one-dimensional tensor. It is also
called a 1D tensor.
2) 1D Tensor (Vector)
It can be confused by the definition of the dimension of the vector and the dimension of the
tensor, where the dimension in the vector means the number of elements placed on one axis,
and the dimension in the tensor means the number of axes.
7. 6
2. Tensors
An array of vectors in which rows and columns exist, i.e., a matrix is called a two-dimensional
tensor, also called a 2D tensor.
3) 2D Tensor (Matrix)
Let's also summarize the shape of the tensor. The size of the tensor is a value that indicates how
many dimensions there are along each axis. It is useful for model design if you can immediately
think of the size of the tensor. It can be difficult at first, but it is also a way to expand it
sequentially. In the above case, there are three large data, and each large data can be thought of
as four small data.
8. 7
3. Sample and Feature
When the input matrix of the training data is X, the definitions of Sample and Feature are as follows.
In machine learning, when data is divided into countable units, each is called a sample,
and each independent variable x for predicting dependent variable y is called a property.
9. 8
4. The operation of vectors and matrices
Addition and subtraction of vectors and matrices
Two vectors or matrices of the same size can be added and subtracted.
In this case, you can perform operations between elements in the same location. These
operations are called element-wise operations.
Let's say that there are two vectors, A and B.
10. 9
4. The operation of vectors and matrices
Addition and subtraction of vectors and matrices
The addition and subtraction of the two vectors A and B are shown below.
11. 10
4. The operation of vectors and matrices
Addition and subtraction of vectors and matrices
The same applies to matrices. Assuming that there are two matrices, A and B, the addition and
subtraction of the matrices A and B are as follows.
13. 12
5. Todo
• 3D tensors (multi-dimensional arrangements)
• Higher tensors
• Multiplication of the inner part of the vector with the matrix
• Understanding as multiple linear regression matrix operations
• Determining the size of weights and deflection matrices
List
There's a lot I haven't understood yet. I'll try to study more.