当前位置:网站首页>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
边栏推荐
- 【软件逆向-求解flag】内存获取、逆变换操作、线性变换、约束求解
- VTK volume rendering program design of 3D scanned volume data
- 37 page overall planning and construction plan for digital Village revitalization of smart agriculture
- Imeta | Chen Chengjie / Xia Rui of South China Agricultural University released a simple method of constructing Circos map by tbtools
- Memory optimization of Amazon memorydb for redis and Amazon elasticache for redis
- The way of intelligent operation and maintenance application, bid farewell to the crisis of enterprise digital transformation
- 2022 PMP project management examination agile knowledge points (9)
- Command line kills window process
- Model-Free Prediction
- 互动滑轨屏演示能为企业展厅带来什么
猜你喜欢

How engineers treat open source -- the heartfelt words of an old engineer

509 certificat basé sur Go

Clipboard management tool paste Chinese version

48 page digital government smart government all in one solution

37 page overall planning and construction plan for digital Village revitalization of smart agriculture

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

英雄联盟|王者|穿越火线 bgm AI配乐大赛分享

从外企离开,我才知道什么叫尊重跟合规…

Data analysis course notes (V) common statistical methods, data and spelling, index and composite index

AI超清修复出黄家驹眼里的光、LeCun大佬《深度学习》课程生还报告、绝美画作只需一行代码、AI最新论文 | ShowMeAI资讯日报 #07.06
随机推荐
js导入excel&导出excel
Devops can help reduce technology debt in ten ways
Win10 startup error, press F9 to enter how to repair?
2022 PMP project management examination agile knowledge points (9)
基於GO語言實現的X.509證書
509 certificat basé sur Go
Alexnet experiment encounters: loss Nan, train ACC 0.100, test ACC 0.100
After leaving a foreign company, I know what respect and compliance are
Why should a complete knapsack be traversed in sequence? Briefly explain
@TableId can‘t more than one in Class: “com.example.CloseContactSearcher.entity.Activity“.
Everyone is always talking about EQ, so what is EQ?
Mujoco second order simple pendulum modeling and control
VTK volume rendering program design of 3D scanned volume data
37页数字乡村振兴智慧农业整体规划建设方案
Data analysis course notes (V) common statistical methods, data and spelling, index and composite index
MySQL learning notes (mind map)
深度学习之环境配置 jupyter notebook
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
C language input / output stream and file operation [II]
Value Function Approximation