当前位置:网站首页>Learning letter cup -train code learning
Learning letter cup -train code learning
2022-07-18 00:51:00 【Zhen xiaopang】
F.nll_loss What is it?
negative likelihood loss
2. nll_loss , The full name of the function is negative log likelihood loss, The function expression is
f(x,class)=-x[class]
for example : hypothesis x=[1,2,3], class=2, be
f(x,class)=-x[2]=-3
pytorch in .item() The role of
pytorch in ,.item() Method Is to get the element value in an element tensor
The concrete is Used to convert a zero dimensional tensor into a floating point number , For example, calculation loss,accuracy Value
Like :
loss = (y_pred - y).pow(2).sum()
print(loss.item())
@torch.no_grad() and model.eval() The difference between
Be wrapped Forward calculation will be carried out for the part of , But it doesn't involve gradient calculation , Speed up calculation , Save computing resources .
because def test Only forward inference, Back propagation is not involved , There's no need to calculate the gradient , Therefore, using torch.no_grad()
model.eval()
The main function is to ensure dropout and batchnorm The normal operation ;
And ensure no back propagation ;
Although there is no back propagation ; However, this operation cannot prevent the calculation of gradient in forward propagation ; use @torch.no_grad() It can prevent the waste of resources caused by gradient calculation in forward calculation
https://blog.csdn.net/weixin_46559271/article/details/10565865
parser = argparse.ArgumentParser Use
model.state_dict() effect
model.reset_parameters()
def test
there test Function is very interesting , Not only forget it test, Also put train、valid and test It's all calculated , Easy to print .
边栏推荐
- MFC | untimely refresh of self drawn CStatic
- 【面试题】在 Queue 中 poll()和 remove()有什么区别
- 003.list!=null和list.size()>0的区别
- Interesting and informative. A cognitive upgrade of zero trust network security architecture
- [Huang ah code] Introduction to MySQL - 3. I use select *, and the boss directly rushed me home by train, but I still bought a station ticket
- Typos (spring daily question 57)
- PAT. A1018 Public Bike Management
- GCC rust is approved to be included in the mainline code base, or will meet you in GCC 13
- [live class] Tencent classroom ----- cloud native tool secondary development training camp based on go language ----- kubernetes operator development
- Red hat official announced the new president and CEO! Paul Cormier, a key figure in transformation, is "retiring"
猜你喜欢
![[step on the pit column] solve the problem that the idea plug-in cannot be found](/img/76/192f6d916cd83cfde77113dfe8a0f0.png)
[step on the pit column] solve the problem that the idea plug-in cannot be found

Uniapp+nodejs realize takeout app project 1- project introduction

【直播课】腾讯课堂------基于GO语言的云原生工具二次开发实战训练营-------Kubernetes Operator开发

【教程】idea插件translation翻译快捷键及翻译设置

034. Code rollback reset current branch to here

Software installation package

Xiaomi has repeatedly violated the GPL agreement and is suspected to be a "recidivist"

蔚来缘何没有产品主义?
![[interview question] what is the difference between poll() and remove() in the queue](/img/5c/2757c1be47d22dbd61510fb2f6e292.png)
[interview question] what is the difference between poll() and remove() in the queue

Prometheus operator deployment
随机推荐
小程序 拉起企业微信进群二维码
聊天软件项目开发1
[mathematical modeling summer training] matlab program design
Xiaomi has repeatedly violated the GPL agreement and is suspected to be a "recidivist"
C language shift operation
ShareIt group's technology strategy - open, self-supporting and advanced layout
Free play noodles
[mathematical modeling summer training] matlab drawing command
【文档熟肉】redis数据类型
Record the first business trip of new programmers
MFC control learning: button
Typos (spring daily question 57)
【源码】ArrayList 和 Vector 的区别是什么,及扩容倍数的区别
洛谷P3194 [HNOI2008]水平可见直线(计算几何+单调栈)
MFC implementation class serialization
1300_ Analysis of priority related knowledge points in FreeRTOS
[learning notes] tree DP
[mathematical modeling summer training] data processing of MATLAB
MySQL advanced (III) summary of cursor simple knowledge points
这段sql在pg执行会报错,Oracle没问题