使用DNN进行图像分类的奇怪输出

我尝试使用微调的CaffeNet网络对图像进行分类。我按照Caffe的教程操作,将训练文件中的输出数量改为3,并且关闭了前两个卷积层的学习。但不知为何,当我使用训练好的模型进行分类时,对于测试集中的每张图像,所有类的输出值都是0.3。

类别数量: 3训练集大小: 6570张图片 (80%)测试集大小: 1645张图片 (20%)

求解器:

net: "train.prototxt"test_iter: 100test_interval: 1000base_lr: 0.0001lr_policy: "step"gamma: 0.1stepsize: 20000display: 200max_iter: 60000momentum: 0.9weight_decay: 0.0005snapshot: 10000snapshot_prefix: "snapshot"solver_mode: GPU

我如何运行训练:

caffe train -solver solver.prototxt -weights bvlc_reference_caffenet.caffemodel

部分输出:

I0531 00:35:52.622647  2944 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:36:02.699782  2944 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:36:03.900009  5528 solver.cpp:218] Iteration 3600 (10.1266 iter/s, 19.7499s/200 iters), loss = 0.679402I0531 00:36:03.900009  5528 solver.cpp:237]     Train net output #0: loss = 0.679402 (* 1 = 0.679402 loss)I0531 00:36:03.900009  5528 sgd_solver.cpp:105] Iteration 3600, lr = 0.0001I0531 00:41:20.139937  2944 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:41:30.934025  2944 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:41:34.199774  5528 solver.cpp:218] Iteration 6800 (9.66881 iter/s, 20.6851s/200 iters), loss = 0.451174I0531 00:41:34.199774  5528 solver.cpp:237]     Train net output #0: loss = 0.451174 (* 1 = 0.451174 loss)I0531 00:41:34.199774  5528 sgd_solver.cpp:105] Iteration 6800, lr = 0.0001I0531 00:41:41.794001  2944 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:41:52.743448  2944 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:41:55.126147  5528 solver.cpp:330] Iteration 7000, Testing net (#0)I0531 00:41:55.891929  3704 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:41:58.393698  3704 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:41:58.862452  5528 solver.cpp:397]     Test net output #0: accuracy = 0.6952I0531 00:41:58.862452  5528 solver.cpp:397]     Test net output #1: loss = 0.873388 (* 1 = 0.873388 loss)I0531 00:43:08.320360  2944 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:43:18.514559  2944 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:43:18.920881  5528 solver.cpp:218] Iteration 7800 (10.0073 iter/s, 19.9854s/200 iters), loss = 0.196175I0531 00:43:18.920881  5528 solver.cpp:237]     Train net output #0: loss = 0.196175 (* 1 = 0.196175 loss)I0531 00:43:18.920881  5528 sgd_solver.cpp:105] Iteration 7800, lr = 0.0001I0531 00:43:28.660408  2944 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:43:38.561293  5528 solver.cpp:330] Iteration 8000, Testing net (#0)I0531 00:43:40.405230  3704 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:43:42.077230  5528 solver.cpp:397]     Test net output #0: accuracy = 0.7004I0531 00:43:42.077230  5528 solver.cpp:397]     Test net output #1: loss = 0.991567 (* 1 = 0.991567 loss)I0531 00:45:22.426592  3704 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:45:24.761165  3704 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:45:25.329238  5528 solver.cpp:397]     Test net output #0: accuracy = 0.6856I0531 00:45:25.329238  5528 solver.cpp:397]     Test net output #1: loss = 1.08582 (* 1 = 1.08582 loss)I0531 00:45:25.394567  5528 solver.cpp:218] Iteration 9000 (8.39955 iter/s, 23.8108s/200 iters), loss = 0.107816I0531 00:45:25.394567  5528 solver.cpp:237]     Train net output #0: loss = 0.107816 (* 1 = 0.107816 loss)I0531 00:46:49.099460  2944 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:46:59.269830  2944 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:47:03.997443  5528 solver.cpp:447] Snapshotting to binary proto file snapshot_iter_10000.caffemodelI0531 00:47:05.185039  5528 sgd_solver.cpp:273] Snapshotting solver state to binary proto file snapshot_iter_10000.solverstateI0531 00:47:05.403774  5528 solver.cpp:330] Iteration 10000, Testing net (#0)I0531 00:47:07.122831  3704 data_layer.cpp:73] Restarting data prefetching from start.I0531 00:47:08.870923  5528 solver.cpp:397]     Test net output #0: accuracy = 0.7012I0531 00:47:08.870923  5528 solver.cpp:397]     Test net output #1: loss = 1.18649 (* 1 = 1.18649 loss)I0531 00:47:08.964664  5528 solver.cpp:218] Iteration 10000 (8.12416 iter/s, 24.6179s/200 iters), loss = 0.0347012I0531 00:47:08.964664  5528 solver.cpp:237]     Train net output #0: loss = 0.0347012 (* 1 = 0.0347012 loss)I0531 00:47:08.964664  5528 sgd_solver.cpp:105] Iteration 10000, lr = 0.0001

我如何运行分类:

classification deploy.prototxt snapshot_iter_10000.caffemodel labels.txt ..\test

部分输出:

"0.jpg",0.333333,0.333333,0.333333"1.jpg",0.333333,0.333333,0.333333"10.jpg",0.333333,0.333333,0.333333"100.jpg",0.333333,0.333333,0.333333"101.jpg",0.333333,0.333333,0.333333"102.jpg",0.333333,0.333333,0.333333,"103.jpg",0.333333,0.333333,0.333333

不知为何,在70%的准确率下,我得到的结果与50%的准确率相同——每个类的输出都是0.3。


回答:

你的分类输出并没有什么奇怪之处,只是你需要正确地解释它。对于3个类别的准确率0.333,这仅仅意味着你的网络没有学到任何东西——它只是在随机猜测。对于N个类别,随机猜测的准确率将是1/N。所以在你的例子中是1/3,即0.333。

现在,虽然设置超参数没有标准规则,但鉴于你的损失值变化很大,我建议你将基础学习率降低到0.00001。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注