我已经使用Keras实现了一个复杂的神经网络。神经网络训练正常,在训练过程中达到100%的准确性。但是,在评估过程中,结果非常低,神经网络的输出始终为0。
首先,我研究了神经网络的权重并发现了一些nan值。我替换了这些值并重新训练了神经网络。训练结束后,权重不再存在nan值。但是,评估结果仍然相同。
出于绝望,我运行以下程序来训练网络:
model.fit(dt[:200],labels[:200],epochs=100,batch_size=10,validation_data=(dt[:200],labels[:200]))
尽管该代码中有很多废话,但我至少希望收到训练和测试集相同的值。但是,这就是我得到的:
Train on 200 samples, validate on 200 samples
Epoch 1/100
200/200 [==============================] - 21s 104ms/step - loss: 0.2230 - acc: 0.9650 - val_loss: 7.9712 - val_acc: 0.5000
Epoch 2/100
200/200 [==============================] - 21s 104ms/step - loss: 0.0302 - acc: 0.9850 - val_loss: 0.7086 - val_acc: 0.5000
Epoch 3/100
200/200 [==============================] - 21s 104ms/step - loss: 0.0353 - acc: 0.9800 - val_loss: 0.7096 - val_acc: 0.5000
Epoch 4/100
200/200 [==============================] - 21s 104ms/step - loss: 0.0349 - acc: 0.9900 - val_loss: 0.7088 - val_acc: 0.5000
Epoch 5/100
200/200 [==============================] - 21s 104ms/step - loss: 0.0298 - acc: 0.9900 - val_loss: 0.7097 - val_acc: 0.5000
Epoch 6/100
200/200 [==============================] - 21s 103ms/step - loss: 0.0457 - acc: 0.9800 - val_loss: 0.7065 - val_acc: 0.5000
Epoch 7/100
200/200 [==============================] - 21s 103ms/step - loss: 0.0060 - acc: 0.9950 - val_loss: 0.7080 - val_acc: 0.5000
Epoch 8/100
200/200 [==============================] - 20s 102ms/step - loss: 0.0337 - acc: 0.9900 - val_loss: 0.7045 - val_acc: 0.5000
Epoch 9/100
200/200 [==============================] - 21s 105ms/step - loss: 0.0048 - acc: 1.0000 - val_loss: 0.7049 - val_acc: 0.5000
Epoch 10/100
200/200 [==============================] - 21s 104ms/step - loss: 0.0020 - acc: 1.0000 - val_loss: 0.7059 - val_acc: 0.5000
完全相同的集合用于训练和评估,但返回不同的损失和准确性值。关于发生了什么的任何想法!!!?