当前位置:网站首页>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
边栏推荐
- System activity monitor ISTAT menus 6.61 (1185) Chinese repair
- PXE server configuration
- uniapp实现从本地上传头像并显示,同时将头像转化为base64格式存储在mysql数据库中
- threejs图片变形放大全屏动画js特效
- rancher集成ldap,实现统一账号登录
- Data operation platform - data collection [easy to understand]
- Leecode brushes questions and records interview questions 01.02 Determine whether it is character rearrangement for each other
- 【YoloV5 6.0|6.1 部署 TensorRT到torchserve】环境搭建|模型转换|engine模型部署(详细的packet文件编写方法)
- Sword finger offer 26 Substructure of tree
- Cross-entrpy Method
猜你喜欢
Mujoco second order simple pendulum modeling and control
Interface master v3.9, API low code development tool, build your interface service platform immediately
stm32F407-------SPI通信
Article management system based on SSM framework
深度学习之数据处理
三维扫描体数据的VTK体绘制程序设计
The way of intelligent operation and maintenance application, bid farewell to the crisis of enterprise digital transformation
Win10 startup error, press F9 to enter how to repair?
Basic information of mujoco
Stm32f407 ------- DAC digital to analog conversion
随机推荐
Use mujoco to simulate Cassie robot
陀螺仪的工作原理
Advanced learning of MySQL -- basics -- multi table query -- self join
build. How to configure the dependent version number in the gradle file
48 page digital government smart government all in one solution
Leecode brushes questions and records interview questions 01.02 Determine whether it is character rearrangement for each other
Leecode brush questions record sword finger offer 44 A digit in a sequence of numbers
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
Devops can help reduce technology debt in ten ways
Clipboard management tool paste Chinese version
基于SSM框架的文章管理系统
Personal digestion of DDD
Stm32f407 ------- DAC digital to analog conversion
How to set encoding in idea
Huawei mate8 battery price_ Huawei mate8 charges very slowly after replacing the battery
Mujoco produces analog video
Leecode brushes questions to record interview questions 17.16 massagist
Zynq transplant ucosiii
JS import excel & Export Excel
@TableId can‘t more than one in Class: “com.example.CloseContactSearcher.entity.Activity“.