PyTorch 02: Matrices
Implementing matrix, and using size()
A matrix has two dimensions, which means… yep, you guessed it, two square brackets!
Now, Let’s start by creating a matrix.
MATRIX = torch.tensor([[3, 4],[4, 5]])
MATRIX
tensor([[3, 4],
[4, 5]])
Let’s check its the size
:
MATRIX.size()
torch.Size([2, 2])
The output torch.Size([2, 2])
indicates that the matrix is two elements deep and two elements wide.