1、介绍
人脸性别检测,数据集采用64X64尺寸的图像,灰度图和RGB图,正负样本各有7000,10000,27000三种,在此过程中发现Accuracy在学习过程中一直保持不变,以下列出针对该问题做的一些尝试。
网络结构:
using conv = tiny_dnn::convolutional_layer;
using pool = tiny_dnn::max_pooling_layer;
using fc = tiny_dnn::fully_connected_layer;
using relu = tiny_dnn::relu_layer;
using softmax = tiny_dnn::softmax_layer;
const size_t n_fmaps = 16; // number of feature maps for upper layer
const size_t n_fmaps2 = 64; // number of feature maps for lower layer
const size_t n_fc = 32; // number of hidden units in fc layer
nn << conv(64, 64, 5, 1, n_fmaps, tiny_dnn::padding::same, true, 2, 2, backend_type) // C1
<< relu()
<< conv(32, 32, 5, n_fmaps, n_fmaps, tiny_dnn::padding::same, true, 2, 2, backend_type) // C2
<< relu()
<< conv(16, 16, 5, n_fmaps, n_fmaps2, tiny_dnn::padding::same, true, 2, 2, backend_type) // C5
<< relu()
<< pool(8, 8, n_fmaps2, 2, backend_type) // P6
<< relu() // activation
<< fc(4 * 4 * n_fmaps2, 3, true, backend_type) // FC7
<< relu() // activation
<< softmax(3); // FC10
2、
1)、shuffle数据集
2)、调整参数 learning_rate,epochs ,minibatch_size,查过网上的一些介绍,有推荐提高batchsize,让每个batch中包含各类样本内
3)、更改标签个数,因为是二类分类,因为训练集中的样本标签也只有0和1,所以一开始只分输出只有2,后来有别人说要多于2,也尝试了。
4)、图像使用灰度图和RBG图都尝试了
5)、改变样本数量,正负各7000,正负各10000,正负各27000
以上的方法都尝试了,结果accuracy一直没变,另外其中调试过程发现网络参数有变为nan的情况,每个卷积层和池化层之后都加了relu,所以后面没发现nan,不过Accuracy也一样还是没变。
然后将最后的softmax(3)改为sigmoid(3),在正负样本各27000结果Accuracy不再一直是0.5,如下图
但是在正负样本各7000的基础上还是0.5
3、参考资料:
1、https://github.com/keras-team/keras/issues/2711
2、https://github.com/keras-team/keras/issues/1006
3、https://github.com/keras-team/keras/issues/1597/
4、https://blog.csdn.net/cym1990/article/details/73387481
5、https://datascience.stackexchange.com/questions/18663/unstable-accuracy-of-cnn-when-should-i-stop-training Unstable accuracy of CNN - When should I stop training?
6、https://talhassner.github.io/home/publication/2015_CVPR/
7、http://lib.csdn.net/article/aimachinelearning/50554
8、https://stackoverflow.com/questions/40367232/error-with-tiny-dnn-for-pedestrian-recognition/
9、https://github.com/tiny-dnn/tiny-dnn/issues/28
10、https://blog.csdn.net/sinat_16823063/article/details/53699849
11、https://stackoverflow.com/questions/33712178/tensorflow-nan-bug Tensorflow NaN bug?
12、https://blog.csdn.net/weixin_38582851/article/details/82222411