当前位置:网站首页>pytorch with torch.no_ grad
pytorch with torch.no_ grad
2022-07-24 14:44:00 【Rihe Princess】
First , About python Medium with:
with Statement is suitable for accessing resources , Make sure that the necessary... Is executed regardless of whether an exception occurs during use “ clear ” operation , Release resources , For example, the file is automatically closed after use / Automatic acquisition and release of locks in threads .
About torch.no_grad()
First of all, from the requires_grad Speak up :
requires_grad
stay pytorch in ,tensor There is one requires_grad Parameters , If set to True, In the case of reverse propagation , The tensor Will automatically take the derivative .tensor Of requires_grad The default attribute of is False, If a node ( Leaf variables : self-created tensor)requires_grad Set to True, Then all nodes that depend on it requires_grad All for True( Even if other dependent tensor Of requires_grad = False)
When requires_grad Set to False when , Back propagation does not automatically take the derivative , Therefore, it greatly saves video memory or memory .
with torch.no_grad The role of
Under this module , All calculated tensor Of requires_grad Are automatically set to False.
Even if one tensor( Name it x) Of requires_grad = True, stay with torch.no_grad Calculation , from x Get new tensor( Name it w- Scalar )requires_grad Also for the False, And grad_fn Also for the None, That's not right w Derivation .
边栏推荐
- pytorch with torch.no_grad
- The spiral matrix of the force buckle rotates together (you can understand it)
- Centos7 installs Damon stand-alone database
- 清除字符串中所有空格
- [oauth2] IV. oauth2authorizationrequestredirectfilter
- Data analysis and mining 2
- Su Chunyuan, founder of science and technology · CEO of Guanyuan data: making business use is the key to the Bi industry to push down the wall of penetration
- 看完这篇文章,才发现我的测试用例写的就是垃圾
- Grpc middleware implements grpc call retry
- spark:指定日期输出相应日期的日志(入门级-简单实现)
猜你喜欢

Decrypt "sea Lotus" organization (domain control detection and defense)

Similarities and differences between nor flash and NAND flash

Unity 委托 (Delegate) 的简单理解以及实现

【NLP】下一站,Embodied AI

Su Chunyuan, founder of science and technology · CEO of Guanyuan data: making business use is the key to the Bi industry to push down the wall of penetration

Mysql库的操作

Dialog manager Chapter 2: create frame window

Learning rate adjustment strategy in deep learning (1)

Error when using Fiddler hook: 502 Fiddler - connection failed

Centos7 installs Damon stand-alone database
随机推荐
VS编译后的应用缺少dll
Summary of Baimian machine learning
C# 多线程锁整理记录
Under multi data source configuration, solve org.apache.ibatis.binding Bindingexception: invalid bound statement (not found) problem
Video game design report template and resources over the years
2.4. properties of special profile
深度学习中的学习率调整策略(1)
exchange
2022 IAA industry category development insight series report - phase II
Production environment tidb cluster capacity reduction tikv operation steps
Clear all spaces in the string
Decrypt "sea Lotus" organization (domain control detection and defense)
Introduction to Xiaoxiong school
Solve the problem that uni starter can log in to wechat with local functions, but fails to log in with cloud functions
Meaning of 7 parameters of thread pool
看完这篇文章,才发现我的测试用例写的就是垃圾
对话框管理器第二章:创建框架窗口
C operator priority memory formula
The fourth edition of Zhejiang University probability proves that the uncorrelation of normal distribution random variables is equivalent to independence
dataframe 分组后排序的前n行 nlargest argmax idmax tail !!!!