当前位置:网站首页>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
边栏推荐
- 同事的接口文档我每次看着就头大,毛病多多。。。
- lambda expressions
- The pit of sizeof operator in C language
- Fs8b711s14 electric wine bottle opener MCU IC scheme development special integrated IC
- 2022.07.03 (LC 6109 number of people who know secrets)
- 微服务(Microservice)那点事儿
- 企业公司项目开发好一部分基础功能,重要的事保存到线上第一a
- 【selenium自动化】常用注解
- 22-07-02周总结
- 用快解析内网穿透实现零成本自建网站
猜你喜欢
【路径规划】RRT增加动力模型进行轨迹规划
[path planning] RRT adds dynamic model for trajectory planning
The waterfall flow layout demo2 (method 2) used by the uniapp wechat applet (copy and paste can be used without other processing)
[IELTS reading] Wang Xiwei reads P4 (matching2 paragraph information matching question [difficult])
「运维有小邓」域密码策略强化器
分布式BASE理论
How to avoid arc generation—— Aafd fault arc detector solves the problem for you
Hisilicon 3559 universal platform construction: YUV422 pit stepping record
他做国外LEAD,用了一年时间,把所有房贷都还清了
JS how to realize array to tree
随机推荐
What did I pay for it transfer to testing post from confusion to firmness?
Consolidated expression C case simple variable operation
海思3559万能平台搭建:YUV422的踩坑记录
Expand your kubecl function
Power operation and maintenance cloud platform: open the new mode of "unattended and few people on duty" of power system
uniapp微信小程序拿来即用的瀑布流布局demo2(方法二)(复制粘贴即可使用,无需做其他处理)
Hologres Query管理及超时处理
2022.07.03 (LC 6109 number of people who know secrets)
圖解網絡:什麼是網關負載均衡協議GLBP?
【C】 (written examination questions) pointer and array, pointer
uniapp上传头像
He worked as a foreign lead and paid off all the housing loans in a year
JS how to realize array to tree
【selenium自动化】常用注解
打新债开户注册安全吗?有没有风险的?靠谱吗?
【C】(笔试题)指针与数组,指针
Hash table, hash function, bloom filter, consistency hash
Significance of acrel EMS integrated energy efficiency platform in campus construction
实战模拟│JWT 登录认证
Go pit - no required module provides Package: go. Mod file not found in current directory or any parent