我正在运行https://keras.io/examples/mnist_cnn/中给出的Mnist示例。几个时期后,精度下降到接近零,所有层权重变为NaN。
x_train shape: (60000, 28, 28, 1)
60000 train samples
10000 test samples
Train on 60000 samples, validate on 10000 samples
Epoch 1/12
60000/60000 [==============================] - 4s 69us/step - loss: 0.2202 - acc: 0.9321 - val_loss: 0.0594 - val_acc: 0.9815
Epoch 2/12
60000/60000 [==============================] - 4s 63us/step - loss: 0.0741 - acc: 0.9773 - val_loss: 0.0392 - val_acc: 0.9871
Epoch 3/12
60000/60000 [==============================] - 4s 63us/step - loss: 0.0345 - acc: 0.6064 - val_loss: 1.1921e-07 - val_acc: 0.0980
Epoch 4/12
60000/60000 [==============================] - 4s 63us/step - loss: 1.1921e-07 - acc: 0.0987 - val_loss: 1.1921e-07 - val_acc: 0.0980
Epoch 5/12
60000/60000 [==============================] - 4s 62us/step - loss: 1.1921e-07 - acc: 0.0987 - val_loss: 1.1921e-07 - val_acc: 0.0980
Epoch 6/12
60000/60000 [==============================] - 4s 63us/step - loss: 1.1921e-07 - acc: 0.0987 - val_loss: 1.1921e-07 - val_acc: 0.0980
Epoch 7/12
60000/60000 [==============================] - 4s 63us/step - loss: 1.1921e-07 - acc: 0.0987 - val_loss: 1.1921e-07 - val_acc: 0.0980
Epoch 8/12
60000/60000 [==============================] - 4s 63us/step - loss: 1.1921e-07 - acc: 0.0987 - val_loss: 1.1921e-07 - val_acc: 0.0980
Epoch 9/12
60000/60000 [==============================] - 4s 63us/step - loss: 1.1921e-07 - acc: 0.0987 - val_loss: 1.1921e-07 - val_acc: 0.0980
Epoch 10/12
60000/60000 [==============================] - 4s 63us/step - loss: 1.1921e-07 - acc: 0.0987 - val_loss: 1.1921e-07 - val_acc: 0.0980
Epoch 11/12
60000/60000 [==============================] - 4s 62us/step - loss: 1.1921e-07 - acc: 0.0987 - val_loss: 1.1921e-07 - val_acc: 0.0980
Epoch 12/12
60000/60000 [==============================] - 4s 63us/step - loss: 1.1921e-07 - acc: 0.0987 - val_loss: 1.1921e-07 - val_acc: 0.0980
Test loss: 1.1920930376163597e-07
Test accuracy: 0.098
for layer in model.layers:
if len(layer.get_weights()) > 0 and np.all(np.isnan(layer.get_weights()[0])):
print(layer.name)
Output:
conv2d_3
conv2d_4
dense_3
dense_4
TensorFlow 1.12.0 Keras 2.2.4 CUDA版本10.0.130 cuDNN 7.3.1