Deep learning from getting started to not wanting to give up-3

 Before I knew it, I had written 5 public accounts, and this series has reached the third chapter. I found that self-motivation is very important in whatever I do. If I find it interesting, I can keep going. If my public account can write When I reach 50 articles, I will go to Qidian.com and open an account to write fairy novels. I think I may be able to keep writing novels.

      Continue to write the basics. The reason why it is so troublesome to learn this thing is that there are too many basics.

Image

      In the previous article, we introduced that you can check the square brackets to determine how many dimensions a tensor has. You can also see it through the number of shapes. At the same time, shape also provides the number of elements in each dimension, as shown in the figure above for each dimension. They are all 1-dimensional, only the last dimension, that is, the column contains 2 elements.

       In addition to shape, you can also use size to view the shape of Tensor.

Image

Image

      The size method can also directly extract the number of elements of the corresponding dimension.

      Today’s focus is on the variants of Tesnor

      Why do we need to modify it? It is to facilitate the multiplication and addition calculations of different Tensors, because the core of deep learning is actually these things.

      Simply change the shape of Tensor, view method

      We first create a Tensor t1 with 1 row and 6 columns

Image

       Then we change it to 2 rows and 3 columns. At this time we call the view method

Image

       You can see that Tensor t1 has changed from 1 row and 6 columns to 2 rows and 3 columns now.

       There is something to note here. The view method does not actually change the physical shape of the Tensor (it does not change the storage method, it just changes the display form of the head). Let us verify it with the code. Now there are two t1 and t2

Guess you like

Origin blog.csdn.net/kingsoftcloud/article/details/134905257
Recommended