SparseCategoricalAccuracy低的情况下,得到的f1_score不一定很低。

今天的实验之中,发现SparseCategoricalAccuracy低的情况下,得到的f1_score不一定很低。
放出实验结果

Epoch 1/20
2133/2133 [==============================] - 883s 396ms/step - loss: 0.5979 - acc: 0.3773

  0%|          | 0/10243 [00:00<?, ?it/s]

len train = 
92187
len test = 
10243

100%|██████████| 10243/10243 [09:15<00:00, 18.45it/s]

验证集
分类1 准确率
0.8818135506877228
分类1 召回率
0.8872373141978472
分类1 f1_score
0.884517118037813
分类2 准确率
0.7912015758371634
分类2 召回率
0.7557227971150831
分类2 f1_score
0.7730553327987167
分类3 准确率
0.6704892966360856
分类3 召回率
0.7302248126561199
分类3 f1_score
0.6990833001195695
current final_score = 
0.7859272331206801
self.best_score = 
0.7859272331206801
Epoch 2/20
2133/2133 [==============================] - 856s 401ms/step - loss: 0.4122 - acc: 0.4304

  0%|          | 2/10243 [00:00<10:06, 16.87it/s]

len train = 
92187
len test = 
10243

100%|██████████| 10243/10243 [08:49<00:00, 19.35it/s]

验证集
分类1 准确率
0.912265154200638
分类1 召回率
0.8793780967025457
分类1 f1_score
0.8955197912135712
分类2 准确率
0.7838157117542823
分类2 召回率
0.8322358105989338
分类2 f1_score
0.8073003802281368
分类3 准确率
0.7415637860082305
分类3 召回率
0.7502081598667777
分类3 f1_score
0.7458609271523179
current final_score = 
0.8164608686361593
self.best_score = 
0.8164608686361593
Epoch 3/20
2133/2133 [==============================] - 857s 402ms/step - loss: 0.3380 - acc: 0.4504

  0%|          | 2/10243 [00:00<10:43, 15.92it/s]

len train = 
92187
len test = 
10243

100%|██████████| 10243/10243 [08:57<00:00, 19.06it/s]

验证集
分类1 准确率
0.8977979492351655
分类1 召回率
0.9125234922262088
分类1 f1_score
0.9051008303677343
分类2 准确率
0.831965868066951
分类2 召回率
0.7949200376293509
分类2 f1_score
0.8130211674150095
分类3 准确率
0.7618283881315157
分类3 召回率
0.791007493755204
分类3 f1_score
0.7761437908496732
current final_score = 
0.8315898908529791
self.best_score = 
0.8315898908529791
Epoch 4/20
2133/2133 [==============================] - 866s 406ms/step - loss: 0.2846 - acc: 0.4642

  0%|          | 2/10243 [00:00<09:51, 17.32it/s]

len train = 
92187
len test = 
10243

100%|██████████| 10243/10243 [09:04<00:00, 18.82it/s]

验证集
分类1 准确率
0.9049241778837962
分类1 召回率
0.9073979155988382
分类1 f1_score
0.9061593584712506
分类2 准确率
0.827977929243752
分类2 召回率
0.7999372844151772
分类2 f1_score
0.8137161084529505
分类3 准确率
0.7795823665893271
分类3 召回率
0.839300582847627
分类3 f1_score
0.8083400160384924
current final_score = 
0.8430373043934679
self.best_score = 
0.8430373043934679
Epoch 5/20
2133/2133 [==============================] - 867s 407ms/step - loss: 0.2384 - acc: 0.4601

  0%|          | 2/10243 [00:00<09:22, 18.20it/s]

len train = 
92187
len test = 
10243

100%|██████████| 10243/10243 [09:07<00:00, 18.71it/s]

验证集
分类1 准确率
0.8970687331536388
分类1 召回率
0.9097898513582778
分类1 f1_score
0.9033845109848163
分类2 准确率
0.7924586143470264
分类2 召回率
0.810598933835058
分类2 f1_score
0.8014261354828709
分类3 准确率
0.8516746411483254
分类3 召回率
0.7410491257285595
分类3 f1_score
0.7925200356188778
current final_score = 
0.8333300646286056
Epoch 6/20
2133/2133 [==============================] - 871s 408ms/step - loss: 0.2016 - acc: 0.4594

  0%|          | 2/10243 [00:00<10:54, 15.64it/s]

len train = 
92187
len test = 
10243

100%|██████████| 10243/10243 [09:07<00:00, 18.70it/s]

验证集
分类1 准确率
0.9220458553791887
分类1 召回率
0.8932171535964463
分类1 f1_score
0.9074025861320837
分类2 准确率
0.8310502283105022
分类2 召回率
0.7989965506428347
分类2 f1_score
0.8147082334132693
分类3 准确率
0.7232913072329131
分类3 召回率
0.9075770191507078
分类3 f1_score
0.8050221565731167
current final_score = 
0.8448123433812292
self.best_score = 
0.8448123433812292
Epoch 7/20
2133/2133 [==============================] - 871s 409ms/step - loss: 0.1727 - acc: 0.4863

  0%|          | 2/10243 [00:00<09:56, 17.17it/s]

len train = 
92187
len test = 
10243

100%|██████████| 10243/10243 [09:07<00:00, 18.72it/s]

验证集
分类1 准确率
0.9165507649513213
分类1 召回率
0.9007346659832565
分类1 f1_score
0.9085738905644118
分类2 准确率
0.8371335504885994
分类2 召回率
0.8058952649733458
分类2 f1_score
0.8212174468764979
分类3 准确率
0.7684729064039408
分类3 召回率
0.9092422980849292
分类3 f1_score
0.8329519450800915
current final_score = 
0.8556414148229328
self.best_score = 
0.8556414148229328

可以发现,这里的SparseCategoricalAccuracy有0.4几,但是得到的f1_score的对应值却并不低。
究其原因是因为,如果损失函数使用的是keras.losses.SparseCategoricalCrossentropy(),这一损失函数正好与准确率keras.metrics.sparse_categorical_accuracy,而如果不使用损失函数SparseCategoricalCrossentropy()的时候,损失函数并不能很好地与sparse_categorical_accuracy配套,所以如果想要f1_score的得分高的时候,keras.metrices.sparse_categorical_accuracy的指标只能作为一个参考指标。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值