当前位置:网站首页>Pytorch's leafnode understanding
Pytorch's leafnode understanding
2022-06-13 01:04:00 【kaims】
https://blog.csdn.net/Azahaxia/article/details/117234505
https://blog.csdn.net/byron123456sfsfsfa/article/details/92210253
Set up requires_grad=True Of tensor Accounting gradient , But not for all requires_grad=True Of tensor Save the gradient . Because in order to reduce video memory / Memory footprint , We won't save the... Generated during the intermediate calculation tensor Gradient of . therefore , With the concept of leaf nodes . If and only if tensor It's a leaf node , And the gradient needs to be calculated , We will save the calculated gradient for it , For back propagation updates .
Leaf nodes : about requires_grad=False perhaps grad_fn=None Of tensor, Both are regarded as leaf nodes , namely is_leaf=True.
analysis : about requires_grad = False Of tensor Come on , We conventionally classify them as leaf tensors . But in fact, no matter how it is divided, it has no effect , Because of the tensor is_leaf Attributes only make sense when they need to be derived . When requires_grad = True When , And when this tensor It's when the user creates , It is a leaf node , When this tensor Is generated by other operations , It is not a leaf node .
Why do I need leaf nodes : As mentioned above , To reduce video memory / Memory footprint , Because we don't want to generate for the intermediate computing process tensor Save the gradient , Even their requires_grad=True( That is, they need to calculate the gradient ).
summary : User built (grad_fn=None) Or you don't need to calculate the gradient (requires_grad=False)tensor It's a leaf node .requires_grad=True Of tensor Nodes need to calculate the gradient , However, the gradient needs to be saved and the tensor It's a leaf node . So , The gradient needs to be saved grad_fn=None and requires_grad=True.
边栏推荐
- How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of strategic returns of vrsi, bbiboll, WR, bias and RSI indicators
- Binary tree - right view
- Quantitative investment traditional index investment decision vs Monte Carlo simulation method
- Canvas random bubbling background
- Leetcode-19- delete the penultimate node of the linked list (medium)
- What is meebits? A brief explanation
- Binary tree -- using hierarchical sequence and middle sequence to determine a tree
- Traditional machine learning classification model predicts the rise and fall of stock prices
- [North Asia server data recovery] data recovery case of Hyper-V service paralysis caused by virtual machine file loss
- Characteristics of transactions -- atomicity (implementation principle)
猜你喜欢

ROS从入门到精通(零) 教程导读

什么是 Meebits?一个简短的解释

Physical orbit simulation

What is the difference between pytorch and tensorflow?

数学知识整理:极值&最值,驻点,拉格朗日乘子

Cards are unpredictable

Et5.0 configuring Excel

How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of strategic benefits of ASI, VR, arbr, DPO and trix indicators

Kotlin coroutine withcontext switch thread

pytorch是什么?解释pytorch的基本概念
随机推荐
Leetcode-11- container with the most water (medium)
蓝桥杯单片机第七届决赛
MySQL exception: com mysql. jdbc. PacketTooBigException: Packet for query is too large(4223215 > 4194304)
Kotlin coroutine withcontext switch thread
[JS] battle chess
Traditional machine learning classification model predicts the rise and fall of stock prices under more than 40 indicators
Introduction to ROS from introduction to mastery (zero) tutorial
软件测试的几种分类,一看就明了
Rotating camera
ArrayList underlying source code
Google play console crash information collection
Leetcode-13- Roman numeral to integer (simple)
How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of strategic returns of vrsi, bbiboll, WR, bias and RSI indicators
[network protocol] problems and solutions in the use of LwIP
Unitywebrequest asynchronous Download
Five classic articles worth reading
Leetcode-17- letter combination of phone number (medium)
Liu Hui and introduction to nine chapter arithmetic and island arithmetic
Canvas game lower level 100
五篇经典好文,值得一看(2)