我正在训练一个神经网络并得到以下输出。loss 和 val_loss 都在减少,这让我很高兴。但是, val_acc 保持不变。那有什么原因呢?我的数据非常不平衡,但我正在通过 sklearncompute_class_weight函数对其进行权衡。Train on 109056 samples, validate on 27136 samplesEpoch 1/200- 1174s - loss: 1.0353 - acc: 0.5843 - val_loss: 1.0749 - val_acc: 0.7871Epoch 00001: val_acc improved from -inf to 0.78711, saving model to nn_best_weights.h5Epoch 2/200- 1174s - loss: 1.0122 - acc: 0.6001 - val_loss: 1.0642 - val_acc: 0.9084Epoch 00002: val_acc improved from 0.78711 to 0.90842, saving model to nn_best_weights.h5Epoch 3/200- 1176s - loss: 0.9974 - acc: 0.5885 - val_loss: 1.0445 - val_acc: 0.9257Epoch 00003: val_acc improved from 0.90842 to 0.92571, saving model to nn_best_weights.h5Epoch 4/200- 1177s - loss: 0.9834 - acc: 0.5760 - val_loss: 1.0071 - val_acc: 0.9260Epoch 00004: val_acc improved from 0.92571 to 0.92597, saving model to nn_best_weights.h5Epoch 5/200- 1182s - loss: 0.9688 - acc: 0.5639 - val_loss: 1.0175 - val_acc: 0.9260Epoch 00005: val_acc did not improve from 0.92597Epoch 6/200- 1177s - loss: 0.9449 - acc: 0.5602 - val_loss: 0.9976 - val_acc: 0.9246Epoch 00006: val_acc did not improve from 0.92597Epoch 7/200- 1186s - loss: 0.9070 - acc: 0.5598 - val_loss: 0.9667 - val_acc: 0.9258Epoch 00007: val_acc did not improve from 0.92597Epoch 8/200- 1178s - loss: 0.8541 - acc: 0.5663 - val_loss: 0.9254 - val_acc: 0.9221Epoch 00008: val_acc did not improve from 0.92597Epoch 9/200- 1171s - loss: 0.7859 - acc: 0.5853 - val_loss: 0.8686 - val_acc: 0.9237Epoch 00009: val_acc did not improve from 0.92597Epoch 10/200- 1172s - loss: 0.7161 - acc: 0.6139 - val_loss: 0.8119 - val_acc: 0.9260
2 回答
烙印99
TA贡献1829条经验 获得超13个赞
似乎是学习率太高,错过了局部最小值,阻碍了神经网络改进学习的情况:
如果您可以自定义优化器,那就太好了,如下所示:
learning_rate = 0.008
decay_rate = 5e-6
momentum = 0.65
sgd = SGD(lr=learning_rate,momentum=momentum, decay=decay_rate, nesterov=False)
model.compile(loss="categorical_crossentropy", optimizer=sgd,metrics=['accuracy'])
另外,增加卷积的数量。权重可能已饱和。
添加回答
举报
0/150
提交
取消