当前位置:网站首页>Linear algebra of deep learning
Linear algebra of deep learning
2022-07-07 00:41:00 【Peng Xiang】
Here we mainly introduce the calculation of some tensors , If sum , Transpose, etc
Scalar operation
import torch
x=torch.tensor(3.0)
y=torch.tensor(4.0)
print(x*y,x+y,x-y,x**y,x/y)# This single element ( Scalar ) It can perform all kinds of four operations
print(x.shape)
Matrix transposition
import torch
x=torch.arange(20).reshape(5,4)
print(x)
print(x.t())# Matrix transposition
B = torch.tensor([[1, 2, 3], [2, 0, 4], [3, 4, 5]])
print(B)
print(B==B.t())# The symmetric matrix is the same as the original matrix after transposition
About python Assignment in , It just assigns the address to a variable , When it changes , Will change together , You can use y=x.clone()
To regenerate data
# Dimension reduction
import torch
A = torch.arange(12, dtype=torch.float32).reshape(3,4)
A_sum_axis0 = A.sum([1])#0 To sum by column ,1 To sum by line ,[0,1] For all , At this point, dimensionality reduction is achieved
print(A,A_sum_axis0, A_sum_axis0.shape)
A = torch.arange(24, dtype=torch.float32).reshape(2,3,4)
sum_A = A.sum(1)#3 Dimension time loses a dimension and becomes a dimension , That is, the row dimension is missing , Empathy ,0 For losing the first ,2 For the third
print(A_sum_axis0)
print(A)
keepdims It will turn the dimension into one
Sum by accumulation
import torch
A = torch.arange(12, dtype=torch.float32).reshape(3,4)
A_sum_axis0=A.cumsum(0)
print(A)
print(A_sum_axis0)
import torch
y = torch.ones(4, dtype = torch.float32)
print(y)
print(torch.dot(y,y))# Vector dot product
y = torch.ones(4, dtype = torch.float32)
x=torch.arange(12,dtype = torch.float32).reshape(3,4)
print(torch.mv(x,y))# vector * matrix
B = torch.ones(4, 3)
print(torch.mm(x, B))# matrix * matrix
边栏推荐
- On February 19, 2021ccf award ceremony will be held, "why in Hengdian?"
- 深度学习之环境配置 jupyter notebook
- [CVPR 2022] semi supervised object detection: dense learning based semi supervised object detection
- iMeta | 华南农大陈程杰/夏瑞等发布TBtools构造Circos图的简单方法
- Alexnet experiment encounters: loss Nan, train ACC 0.100, test ACC 0.100
- ZYNQ移植uCOSIII
- uniapp中redirectTo和navigateTo的区别
- [CVPR 2022] target detection sota:dino: Detr with improved detecting anchor boxes for end to end object detection
- Mujoco produces analog video
- [2022 the finest in the whole network] how to test the interface test generally? Process and steps of interface test
猜你喜欢
Uniapp uploads and displays avatars locally, and converts avatars into Base64 format and stores them in MySQL database
互动滑轨屏演示能为企业展厅带来什么
37 pages Digital Village revitalization intelligent agriculture Comprehensive Planning and Construction Scheme
AI super clear repair resurfaces the light in Huang Jiaju's eyes, Lecun boss's "deep learning" course survival report, beautiful paintings only need one line of code, AI's latest paper | showmeai info
深度学习之环境配置 jupyter notebook
Lombok 同时使⽤ @Data 和 @Builder 的坑,你中招没?
37页数字乡村振兴智慧农业整体规划建设方案
[2022 the finest in the whole network] how to test the interface test generally? Process and steps of interface test
Everyone is always talking about EQ, so what is EQ?
AI超清修复出黄家驹眼里的光、LeCun大佬《深度学习》课程生还报告、绝美画作只需一行代码、AI最新论文 | ShowMeAI资讯日报 #07.06
随机推荐
Wechat applet UploadFile server, wechat applet wx Uploadfile[easy to understand]
Mujoco Jacobi - inverse motion - sensor
Liuyongxin report | microbiome data analysis and science communication (7:30 p.m.)
alexnet实验偶遇:loss nan, train acc 0.100, test acc 0.100情况
Interesting wine culture
Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
学习使用代码生成美观的接口文档!!!
Attention SLAM:一种从人类注意中学习的视觉单目SLAM
The difference between redirectto and navigateto in uniapp
陀螺仪的工作原理
深度学习之数据处理
Advanced learning of MySQL -- basics -- transactions
Notes of training courses selected by Massey school
Imeta | Chen Chengjie / Xia Rui of South China Agricultural University released a simple method of constructing Circos map by tbtools
Leecode brushes questions and records interview questions 01.02 Determine whether it is character rearrangement for each other
Uniapp uploads and displays avatars locally, and converts avatars into Base64 format and stores them in MySQL database
@TableId can‘t more than one in Class: “com.example.CloseContactSearcher.entity.Activity“.
rancher集成ldap,实现统一账号登录
5种不同的代码相似性检测,以及代码相似性检测的发展趋势
What can the interactive slide screen demonstration bring to the enterprise exhibition hall