1
00:00:00,080 --> 00:00:04,520
In this section, we shall start with tensor basics.

2
00:00:04,550 --> 00:00:08,330
Then we'll move on to casting and tensor flow.

3
00:00:08,360 --> 00:00:18,650
We'll look at initialization, indexing, broadcasting, algebraic operations, matrix operations,

4
00:00:18,650 --> 00:00:21,980
commonly used functions in machine learning.

5
00:00:22,010 --> 00:00:29,780
We'll look at the different types of tensors, like the ranked tensors, sparse tensors and even the

6
00:00:29,780 --> 00:00:33,980
string tensors in the context of deep learning.

7
00:00:34,010 --> 00:00:39,680
Tensors can be defined as multi-dimensional arrays.

8
00:00:39,830 --> 00:00:45,170
An array itself is an ordered arrangement of numbers.

9
00:00:45,200 --> 00:00:52,280
It's important we take note of these keywords as the data we shall be dealing with.

10
00:00:52,280 --> 00:01:01,830
Like, for example, this image right here can be represented using this numbers which have been arranged

11
00:01:01,830 --> 00:01:07,890
clearly in an ordered manner and can be represented in multiple dimensions.

12
00:01:07,890 --> 00:01:15,780
In this specific case, we have this array which is represented in one two dimensions.

13
00:01:15,780 --> 00:01:24,600
So this is A to Z or two dimensional array or what we generally call a matrix.

14
00:01:25,300 --> 00:01:31,300
Now we'll explore different types of arrays based on their dimensionality.

15
00:01:31,330 --> 00:01:40,450
So here, for example, we have what we'll call a zero dimensional array, which is simply because this

16
00:01:40,450 --> 00:01:44,500
array or this tensor contains a single element.

17
00:01:44,500 --> 00:01:46,930
So let's say we have 21.

18
00:01:46,960 --> 00:01:49,150
This is a zero dimensional array.

19
00:01:49,150 --> 00:01:52,690
Let's say we have one, this is zero dimensional, so on and so forth.

20
00:01:52,690 --> 00:01:59,080
So essentially once we have a single element, then it's A0D array.

21
00:01:59,840 --> 00:02:09,140
And then now for our next example, we have this 1D tensor right here, which in fact is a combination

22
00:02:09,140 --> 00:02:12,080
of several zero D tensors.

23
00:02:12,080 --> 00:02:18,950
So if you look at this, you see that this is A0D tensor, this is another zero D tensor, this is another

24
00:02:18,950 --> 00:02:19,910
zero D tensor.

25
00:02:19,910 --> 00:02:23,840
So this vector is made of three of these kinds of elements.

26
00:02:23,870 --> 00:02:26,300
Now, we could have other examples like this.

27
00:02:26,300 --> 00:02:32,900
Let's say we have five, um, eight and then three.

28
00:02:33,290 --> 00:02:35,420
Oh, let's, let's, let's change the length.

29
00:02:35,420 --> 00:02:44,330
So let's say we have one of length five, for example, we could have ten two, 11, four and seven.

30
00:02:44,330 --> 00:02:49,520
So this is a 1D tensor we have right here.

31
00:02:49,520 --> 00:02:58,010
So, so far we've looked at the zero D tensor, we've looked at the 1D tensor and now we could dive

32
00:02:58,010 --> 00:03:06,660
into the 2D tensor, which essentially is made of a combination of several 1D tensors.

33
00:03:06,660 --> 00:03:07,950
You could see that right here.

34
00:03:07,950 --> 00:03:15,240
This is a 1D tensor here, this is another 1D tensor, this is another 1D tensor.

35
00:03:15,420 --> 00:03:19,110
And finally here we have a 1D tensor.

36
00:03:19,110 --> 00:03:27,000
So when you bring together this 1D tensors, you form this 2D tensor for a three dimensional tensor.

37
00:03:27,000 --> 00:03:28,590
You might have guessed this right?

38
00:03:28,590 --> 00:03:33,060
You would simply combine several two dimensional tensors.

39
00:03:33,060 --> 00:03:44,940
So right here we have this 2D tensor with this other 2D, with this other 2D and this other 2D forming

40
00:03:44,970 --> 00:03:48,480
a 3D tensor.

41
00:03:48,840 --> 00:03:51,240
We could visualize this differently here.

42
00:03:51,240 --> 00:03:55,020
So we take this, this, this and this.

43
00:03:55,050 --> 00:04:02,100
Now you see we have one, two and the third dimension.

44
00:04:02,100 --> 00:04:08,220
Now that we understand this, we are going to take a look at the concept of tensor shapes, starting

45
00:04:08,220 --> 00:04:08,850
with this.

46
00:04:08,850 --> 00:04:14,490
Given that it's zero dimensional, then there is no shape with this one here.

47
00:04:14,490 --> 00:04:18,810
It's one dimensional and it's made of three elements.

48
00:04:19,110 --> 00:04:22,260
And so we could say this is of shape three.

49
00:04:22,650 --> 00:04:26,130
So we have three and that's it.

50
00:04:26,310 --> 00:04:41,550
Now for this other one, it's made of one, two, three and four 1D tensors, and each and every one

51
00:04:41,550 --> 00:04:44,310
of these is made of three elements.

52
00:04:44,310 --> 00:04:47,910
So this here, for example, is made of three elements.

53
00:04:47,910 --> 00:04:50,520
This made of three, this three, this three.

54
00:04:50,520 --> 00:04:58,200
And given that there are four of this made of three elements, its shape is four by three.

55
00:04:58,350 --> 00:04:59,670
So that's it.

56
00:04:59,670 --> 00:05:01,770
That's how we obtain the shape for this.

57
00:05:01,800 --> 00:05:11,520
Now for the 3D tensor we have here is made of one, two, three, four 2D tensors.

58
00:05:11,520 --> 00:05:20,340
So this year we have four two uh, 2d tensors and each and every one of these is made of two 1D tensors

59
00:05:20,340 --> 00:05:23,910
where each and every one is made of three elements.

60
00:05:23,910 --> 00:05:35,340
So what we'll see here is this is two by three this year because we have one, two is two by three,

61
00:05:35,370 --> 00:05:41,940
this is two by three and this here is two by three.

62
00:05:41,940 --> 00:05:50,100
And now given that we have four of this different two by three 2D tensors, then we would say the shape

63
00:05:50,100 --> 00:05:56,250
of this 3D tensor is four by two by three.

64
00:05:56,280 --> 00:05:59,070
So similar to this, we have four by three.

65
00:05:59,100 --> 00:06:02,340
This is four by two by three.

66
00:06:02,370 --> 00:06:09,000
Now notice that the number of elements we have here tells us or gives us information about the number

67
00:06:09,000 --> 00:06:11,190
of dimensions our tensor is.

68
00:06:11,190 --> 00:06:17,970
So here because we have a 1D tensor or one dimensional tensor, we have just one here because it's 2D

69
00:06:18,000 --> 00:06:23,580
or two dimensional, we have two and here because it's 3D, we have three.

70
00:06:24,450 --> 00:06:34,200
Also in matrix notation, we would say that this year or this matrix right here is made of one two.

71
00:06:35,230 --> 00:06:39,100
Three and four rows.

72
00:06:39,100 --> 00:06:41,980
So number of rows we have here is four.

73
00:06:41,980 --> 00:06:48,220
And then here we have one, two, three columns.

74
00:06:48,250 --> 00:06:52,060
Number of columns is three.

75
00:06:52,630 --> 00:07:03,940
In the case of this 3D tensor we have right here, we have one two rows and one, two, three columns

76
00:07:03,940 --> 00:07:08,590
for each and every one of this 2D tensor we have right here.
