当前位置:网站首页>Pytoch uses torchnet Classerrormeter in meter
Pytoch uses torchnet Classerrormeter in meter
2022-07-05 12:26:00 【Dongcheng West que】
Use torchnet.meter Medium ClassErrorMeter seek Top-x Score
from torchnet.meter import ClassErrorMeter
# Other omitted
metric = [ClassErrorMeter([1,2], True)] # Calculation top-1 top-2 ACCtake metric Transfer to training class

Call in the training function or verification function metric
if self.metric is not None: # every last epoch Reset , Calculate each epoch The accumulation of acc
self.metric[0].reset()
if self.metric is not None:
prob = F.softmax(outputs, dim=1).data.cpu()
self.metric[0].add(prob, labels.data.cpu()) # Add to metric[0]Print out
if i == len(self.train_data_loader) - 1 and self.metric is not None:
top1_acc_score = self.metric[0].value()[0]
top2_acc_score = self.metric[0].value()[1]Accumulating top-1 acc You can also use the following methods
# stay for Define before the loop
presum = 0
for i, (inputs, labels) in enumerate(self.train_data_loader):
#....
prob = F.softmax(outputs, dim=1).data.cpu()
pre=torch.argmax(prob, 1)
a=(pre==labels.data.cpu()).int()
presum+=a.sum().numpy()
acc=100*presum/len(train_datasets)
边栏推荐
- Summary of C language learning problems (VS)
- Learn the garbage collector of JVM -- a brief introduction to Shenandoah collector
- ACID事务理论
- Wireless WiFi learning 8-channel transmitting remote control module
- How to recover the information server and how to recover the server data [easy to understand]
- HiEngine:可媲美本地的云原生内存数据库引擎
- II. Data type
- MySQL view
- Constructing expression binary tree with prefix expression
- Master-slave mode of redis cluster
猜你喜欢

Matlab boundarymask function (find the boundary of the divided area)

Matlab superpixels function (2D super pixel over segmentation of image)
Two minutes will take you to quickly master the project structure, resources, dependencies and localization of flutter

Matlab label2idx function (convert the label matrix into a cell array with linear index)
Take you two minutes to quickly master the route and navigation of flutter

Read and understand the rendering mechanism and principle of flutter's three trees

Uniapp + unicloud + Unipay realize wechat applet payment function

Why learn harmonyos and how to get started quickly?
![[pytorch modifies the pre training model: there is little difference between the measured loading pre training model and the random initialization of the model]](/img/ad/b96e9319212cf2724e0a640109665d.png)
[pytorch modifies the pre training model: there is little difference between the measured loading pre training model and the random initialization of the model]

Third party payment interface design
随机推荐
互联网公司实习岗位选择与简易版职业发展规划
[pytorch pre training model modification, addition and deletion of specific layers]
Master the new features of fluent 2.10
IPv6与IPv4的区别 网信办等三部推进IPv6规模部署
The evolution of mobile cross platform technology
About cache exceptions: solutions for cache avalanche, breakdown, and penetration
MySQL storage engine
[pytorch modifies the pre training model: there is little difference between the measured loading pre training model and the random initialization of the model]
Intern position selection and simplified career development planning in Internet companies
【ijkplayer】when i compile file “compile-ffmpeg.sh“ ,it show error “No such file or directory“.
II. Data type
Linux安装部署LAMP(Apache+MySQL+PHP)
MySQL index - extended data
GPS数据格式转换[通俗易懂]
[hdu 2096] Xiaoming a+b
Why learn harmonyos and how to get started quickly?
Understand kotlin from the perspective of an architect
Uniapp + unicloud + Unipay realize wechat applet payment function
Image hyperspectral experiment: srcnn/fsrcnn
Conversion du format de données GPS [facile à comprendre]