[Music] in deep learning is common to see a lot of discussions around tensor as the cornerstone data structure tensor even appears in name of google's flagship machine learning library tensorflow tensor are types of data structure used in linear algebra and like vectors like matrices you can perform some mathematical operations with tensor in this videos you will discover what tensor are and how to manipulate them in python with numpy mathematically a tensor is a generalization of vectors and matrices with the context of tensorflow a tensor is considered as a multi-dimensional array with the use of numpy methods it's possible for us to communicate with the tensor with the use of a numpy array in that case here you can see that tensor can be explicitly converted to numpy and the arrays objects into a tensorflow object so similar to numpy's nd arrays 10 several objects and tensor objects have a data types and also have a shape and of course their mathematical operations are also similar to numpy however unlike numpy array tensorflow objects tensors can be backed or can be accelerated by the accelerator memory it means that it's possible for us to use the gpu or even the tpus for them to improve or to accelerate the mathematical operations tensorflow offers rich libraries of operations that consume and produce tensorflow's objects such as the tf.net that is then addition functions and such as the tf.matmul that is the matrix manipulations and so and so these operations automatically convert native python types let's have a very quick example for a additions and also for a matrix multiplications mathematical operations first thing first we import the tensorflow and then we try to use the tensorflow.app functions to add two vectors together on the other hand for the tf that matrix manipulations we try to create two matrices or you can consider this like a two vectors that they try to multiply by each other's of course the first um the first matrix we try to set it let's say shaped that is one two and then the second matrix um we set the shapes that is equals to two one and then in that case we can perform that um the matrix multiplications that's one cell and you can see that some for the first um the tensorflow addition functions uh we created two vectors that is one three plus five sevens and then it will add this and add these two elements and that is one five and then it will again add these two elements uh three plus seven so it's just like a any memorized mathematical operations and then for the matrix multiplications and you can see that we have that 26 that is um 1 3 1 3 and then multiply by 5 7 and then later on we just summar sum up all these elements together to get the matrix multiplications results now if we move on we can try to understand the numpy because now we know that tensorflow is actually i mean sorry i mean tensor is actually quite similar to numpy and built-in in terms of the operations so now let's try to understand the numpy and first thing first we try to understand the axis rank and also dimensions of the numpy um in pythons you know the knees can also the tuple can actually start by in a rate which can be a one array just like a vector or 2 doh just like a matrix or even higher dimension just like this 3d array and to improve the computational efficiency numpy's requires each await with fixed structure and that structure is can be defined by shapes let's take a look on an example in order for us to understand what is say 1d 2d and also 3d numpy array first thing first we import the numpy as mp and here you can see that we try to use one layer of brackets and put everything inside this one layer of brackets to create a 1d shape or one dr8 on the other hand in order for us to create a 2d shape or 2d array we need to have two layers of brackets and then the first layer is a one-two and then the first layer is three four and then the for the second layer that is another brackets that is outside these one two v4 group all these um three so we just try to put everything inside these uh a and other brackets in order for us to create in another a 2d away and then let me show you the result first and then you can see that the shape is like a full commerce and then um there's nothing here that means it's just like a 1d array with four elements and then for the second one that is a two by two matrix and just like these two d away one two three four remember that we use um the brackets to separate um that to define whether it's a 1d 2d or a 3d or even higher dimensions in array now let's move on to the um to the 3d array we can consider a 3d rate um the arrangement is like this we have three level the first level is one two three four matrix and the second level is one two v4 matrix and the final level is another one two v4 matrix and then we can have a larger brackets or the the another bracket and then with some car with two commas to separate them into uh to separate them to separate each of the matrix and then we can group everything inside these large brackets and similarly to how we create a 2d array we can just continue to separate them with another two level of brackets just like what we showed here and finally we can put everything together into these mp away functions to create a 3d array now if i run this cell you can see that we have three matrix that let's um what we show here and then for each of the matrix that let's say 2 by 2 matrix so we have three matrix and each of them is 2 by 2 just like what we show here and finally we can try to understand um uh how these operates and there's two uh we mark the first remark is that some elements from left to right in the shape represent the layers of arrays from outside to inside for example we have a shaped two free represent that there are two subarrays and then inside each of the two subarray there are three elements and then say for example we have another shape that is two three four that means uh it represent that there are two sub-array and inside each of the two sub-arrays there are another three sub arrays and then inside each of the three sub arrays there are four elements therefore we can try to understand that elements from left to right in the shapes represent the layer of array from outside to inside um on the other hand in numpy dimensions are called s's and then the number of assets is actually wang so sometimes you might heard that some some people might think there's one one when two matrix and in each of the assets the number of elements are called dimensions or the length so for example the shaped way that is a one two three uh four five six this is that has a shape that is a two free therefore it has two assets and then the first asset is one two three and then the second asset is four five six and then in the first asset it has it actually has the two dimensions because it has a one two three and four five six therefore it has some two dimensions and then in the second access it has a three dimension statistic one two three inside this s and then four five six this this access and then we typically refer a 1d array as a vector and 2d array as a matrix and say for example at the very beginning we have a shape for commerce without anything that is a four dimensions vector and then we also have another two by two matrix that has a shaped two by two it's a two by two matrix so we got the one d arrays as a vector and two d array assay matrix to avoid any confusions we followed a numpy's logic that's it one d is an array with one axis 2d is an array with two assets and 3d is an await with free assets and so on in this video we just had a very quick introduction of tensors and how it is related to numpy in addition we also introduced the structure and shapes of numpy in the next video we will talk about the basic properties and attribute of numpy see you in the next video bye