当前位置:网站首页>PyTorch: In-place Operation
PyTorch: In-place Operation
2022-07-05 00:26:00 【harry_ tea】
Contents of this article
In-place Operation
In-place operation stay pytorch Middle refers to support in situ modification tensor, This can avoid new memory overhead , Mainly to reduce the consumption of video memory
But in pytorch When back propagating to get the calculation graph, you need to obtain the value of the intermediate variable , If you use in-place After the operation, the intermediate value is lost , Unable to get calculation diagram , But why are some activation functions written in-place Operation? ?
With ReLU Function as an example , It does not change when the input value is positive in-place Whether it does not affect the result ; When the input is negative, it is 0 No back propagation, so it doesn't affect
common In-place operation
1. Symbolic calculation
*=+= Wait for the operation
stay pytorch Try to avoid
tensor = torch.tensor([[1,2,3], [4,5,6]])
print(tensor.data_ptr())
tensor += 2
print(tensor.data_ptr())
tensor = tensor+2
print(tensor.data_ptr())
''' 140430616339712 140430616339712 # in-place 140430616321664 # out-of-place '''
( Continue to supplement )
common Out-of-place operation
1. Symbolic calculation
a=a+b etc. , Reference resources In-place operation
边栏推荐
- 「运维有小邓」域密码策略强化器
- JS how to realize array to tree
- Summer challenge brings you to play harmoniyos multi terminal piano performance
- Data on the number of functional divisions of national wetland parks in Qinghai Province, data on the distribution of wetlands and marshes across the country, and natural reserves in provinces, cities
- What is the difference between port mapping and port forwarding
- 基本放大电路的学习
- Continuous modification of business scenario functions
- 如何将自己的代码作品快速存证,已更好的保护自己劳动成果
- Huawei employs data management experts with an annual salary of 2million! The 100 billion market behind it deserves attention
- 2022.07.03(LC_6111_统计放置房子的方式数)
猜你喜欢

Application of fire fighting system based on 3D GIS platform

Specification for fs4061a boost 8.4v charging IC chip and fs4061b boost 12.6V charging IC chip datasheet

Verilog tutorial (11) initial block in Verilog

多回路仪表在基站“转改直”方面的应用

Microservice

What is the difference between port mapping and port forwarding

如何避免电弧产生?—— AAFD故障电弧探测器为您解决

圖解網絡:什麼是網關負載均衡協議GLBP?

He worked as a foreign lead and paid off all the housing loans in a year

Fast analysis -- easy to use intranet security software
随机推荐
业务实现-日志写到同一个行数据里面
【路径规划】RRT增加动力模型进行轨迹规划
【北京大学】Tensorflow2.0-1-开篇
巩固表达式C# 案例简单变量运算
Réseau graphique: Qu'est - ce que le Protocole d'équilibrage de charge de passerelle glbp?
"Xiaodeng" domain password policy enhancer in operation and maintenance
Fast parsing intranet penetration helps enterprises quickly achieve collaborative office
Hologres query management and timeout processing
[monitoring] ZABBIX
JS convert pseudo array to array
Acwing164. Accessibility Statistics (topological sorting +bitset)
Instructions for go defer
企业公司项目开发好一部分基础功能,重要的事保存到线上第一a
[paper reading] cavemix: a simple data augmentation method for brain vision segmentation
lambda expressions
uniapp上传头像
How to save your code works quickly to better protect your labor achievements
Expand your kubecl function
TS快速入门-函数
Continuous modification of business scenario functions