当前位置:网站首页>[pytorch 07] hands on deep learning chapter_ Preliminaries/ndarray exercises hands-on version
[pytorch 07] hands on deep learning chapter_ Preliminaries/ndarray exercises hands-on version
2022-07-07 10:44:00 【ECCUSXR】
Catalog
3. Through tensor shape Property to access the tensor x( Length along each axis ) The shape of the
4. Just want to know the total number of elements in the tensor , You can check its size (size)
5. Put tensor x From shape to (12,) The row vector of is transformed into a shape of (3,4) Matrix .
6. Create a shape as (2,3,4) Tensor , All elements are set to 0.
7. Create a shape as (2,3,4) Tensor , All elements are set to 1.
9. torch.tensor Create a (3,4) Two dimensional array of .
10. Realize the addition, subtraction, multiplication and division of the following two arrays
11. Exponentiate the following array
12. The following two arrays , Press the line / Splicing by columns
13. Judge whether each element of the following two homogeneous arrays is equal
14. Calculation X The sum of all elements in the array
15. Use arange Create a 3*1 Array of a and 1*2 Array of b
16. Try adding the above two arrays directly , View the situation .
19、 Modify two-dimensional array X The first 0 Xing He 1 All elements of the row are 12.
20、 take X Turn into numpy Assign to A, then A Turn into tensor In the form of B
21、 Output a Original number of 、 Character 、 floating-point
1. Import torch
2. Use arange Create a row vector x, This row vector contains the following elements 0 Before we start 12 It's an integer .
3. Through tensor shape Property to access the tensor x( Length along each axis ) Of shape
4. Just want to know the total number of elements in the tensor , You can check its size (size)
5. Put tensor x From shape to (12,) The row vector of is transformed into a shape of (3,4) Matrix .
6. Create a shape as (2,3,4) Tensor , All elements are set to 0.
7. Create a shape as (2,3,4) Tensor , All elements are set to 1.
8. Create a shape as (3,4) Tensor . Each of these elements has a mean value of 0、 The standard deviation is 1 The standard Gaussian distribution of ( Normal distribution ) Medium random sampling .
9. torch.tensor Create a (3,4) Two dimensional array of .
【 Operator 】
10. Realize the addition, subtraction, multiplication and division of the following two arrays
x = torch.tensor([1.0, 2, 4, 8])
y = torch.tensor([2, 2, 2, 2])11. Exponentiate the following array
x = torch.tensor([1.0, 2, 4, 8])12. The following two arrays , Press the line / Splicing by columns
X = torch.arange(12, dtype=torch.float32).reshape((3,4))
Y = torch.tensor([[2.0, 1, 4, 3], [1, 2, 3, 4], [4, 3, 2, 1]])13. Judge whether each element of the following two homogeneous arrays is equal
X = torch.arange(12, dtype=torch.float32).reshape((3,4))
Y = torch.tensor([[2.0, 1, 4, 3], [1, 2, 3, 4], [4, 3, 2, 1]])14. Calculation X The sum of all elements in the array
X = torch.arange(12, dtype=torch.float32).reshape((3,4))【 Broadcast mechanism 】
15. Use arange Create a 3*1 Array of a and 1*2 Array of b
16. Try adding the above two arrays directly , View the situation .
【 Index and slice 】
17. Take out the two-dimensional array X in choice The last line of elements 、 The second to third lines of elements
X = torch.arange(12, dtype=torch.float32).reshape((3,4))18、 Modify two-dimensional array X The first 1 Xing di 2 The value of the column is 9 and Write matrix
X = torch.arange(12, dtype=torch.float32).reshape((3,4))19、 Modify two-dimensional array X The first 0 Xing He 1 All elements of the row are 12.
X = torch.arange(12, dtype=torch.float32).reshape((3,4))【 Convert objects 】
20、 take X Turn into numpy Assign to A, then A Turn into tensor In the form of B
X = torch.arange(12, dtype=torch.float32).reshape((3,4))21、 Output a Original number of 、 Character 、 floating-point
a = torch.tensor([3.5])边栏推荐
- How to successfully pass the senior system architecture designer in the second half of the year?
- 软考中级有用吗??
- ThreadLocal会用可不够
- Some online academic report websites and machine learning videos
- Common shortcut keys in IDA
- TypeScript 接口继承
- @Configuration, use, principle and precautions of transmission:
- What are the test preparation materials and methods for soft exam information processing technicians?
- BUUCTF---Reverse---reverse1
- Socket communication principle and Practice
猜你喜欢

软考信息处理技术员有哪些备考资料与方法?

中级软件评测师考什么

Leetcode-304: two dimensional area and retrieval - matrix immutable

Mendeley -- a free document management tool that automatically inserts references into papers
![[recommendation system 01] rechub](/img/92/c14c867247d3a042c69b5ed0091fbe.png)
[recommendation system 01] rechub

Application of OpenGL gllightfv function and related knowledge of light source

China Southern Airlines pa3.1

Basic introduction of yarn and job submission process

P1223 排队接水/1319:【例6.1】排队接水
![[daiy5] jz77 print binary tree in zigzag order](/img/ba/b2dfbf121798757c7b9fba4811221b.png)
[daiy5] jz77 print binary tree in zigzag order
随机推荐
软考中级有用吗??
[STM32] solution to the problem that SWD cannot recognize devices after STM32 burning program
[email protected] can help us get the log object quickly
Hdu-2196 tree DP learning notes
简单易修改的弹框组件
TypeScript 接口继承
IDA中常见快捷键
Installation and configuration of slurm resource management and job scheduling system
BUUCTF---Reverse---reverse1
Socket communication principle and Practice
Five simple and practical daily development functions of chrome are explained in detail. Unlock quickly to improve your efficiency!
@Configuration, use, principle and precautions of transmission:
Prototype and prototype chain
[pro test feasible] error while loading shared libraries solution
P1031 [noip2002 improvement group] average Solitaire
OpenGL glLightfv 函数的应用以及光源的相关知识
【OneNote】无法连接到网络,无法同步问题
The mobile terminal automatically adjusts the page content and font size by setting rem
【推薦系統 01】Rechub
Jump to the mobile terminal page or PC terminal page according to the device information