当前位置:网站首页>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 ACC
take 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)
边栏推荐
- Get the variable address of structure member in C language
- MySQL splits strings for conditional queries
- MySQL index - extended data
- About cache exceptions: solutions for cache avalanche, breakdown, and penetration
- Array cyclic shift problem
- Video networkstate property
- Why do you always fail in automated tests?
- ZABBIX agent2 monitors mongodb nodes, clusters and templates (official blog)
- 【ijkplayer】when i compile file “compile-ffmpeg.sh“ ,it show error “No such file or directory“.
- Learn memory management of JVM 01 - first memory
猜你喜欢
互联网公司实习岗位选择与简易版职业发展规划
Implementing Yang Hui triangle with cyclic queue C language
C language structure is initialized as a function parameter
[pytorch modifies the pre training model: there is little difference between the measured loading pre training model and the random initialization of the model]
mmclassification 训练自定义数据
Understand redis persistence mechanism in one article
Redis's memory elimination mechanism, read this article is enough.
abap查表程序
Third party payment interface design
Average lookup length when hash table lookup fails
随机推荐
MySQL basic operation -dql
abap查表程序
mysql拆分字符串做条件查询
MySQL index (1)
想问问,如何选择券商?在线开户是很安全么?
GPS数据格式转换[通俗易懂]
Get data from the database when using JMeter for database assertion
Mmclassification training custom data
Is investment and finance suitable for girls? What financial products can girls buy?
MySQL data table operation DDL & data type
Design of music box based on assembly language
一款新型的智能家居WiFi选择方案——SimpleWiFi在无线智能家居中的应用
Matlab boundarymask function (find the boundary of the divided area)
Intern position selection and simplified career development planning in Internet companies
Linux Installation and deployment lamp (apache+mysql+php)
Want to ask, how to choose a securities firm? Is it safe to open an account online?
mmclassification 训练自定义数据
Semantic segmentation experiment: UNET network /msrc2 dataset
Understand redis persistence mechanism in one article
语义分割实验:Unet网络/MSRC2数据集