我正在训练一个神经网络,并获得以下输出。损失和val_loss都在减少,这让我很高兴。但是,val_acc保持不变。那有什么原因呢?我的数据非常不平衡,但是我正在通过sklearn compute_class_weight
函数对其进行加权。
Train on 109056 samples, validate on 27136 samples
Epoch 1/200
- 1174s - loss: 1.0353 - acc: 0.5843 - val_loss: 1.0749 - val_acc: 0.7871
Epoch 00001: val_acc improved from -inf to 0.78711, saving model to
nn_best_weights.h5
Epoch 2/200
- 1174s - loss: 1.0122 - acc: 0.6001 - val_loss: 1.0642 - val_acc: 0.9084
Epoch 00002: val_acc improved from 0.78711 to 0.90842, saving model to
nn_best_weights.h5
Epoch 3/200
- 1176s - loss: 0.9974 - acc: 0.5885 - val_loss: 1.0445 - val_acc: 0.9257
Epoch 00003: val_acc improved from 0.90842 to 0.92571, saving model to
nn_best_weights.h5
Epoch 4/200
- 1177s - loss: 0.9834 - acc: 0.5760 - val_loss: 1.0071 - val_acc: 0.9260
Epoch 00004: val_acc improved from 0.92571 to 0.92597, saving model to
nn_best_weights.h5
Epoch 5/200
- 1182s - loss: 0.9688 - acc: 0.5639 - val_loss: 1.0175 - val_acc: 0.9260
Epoch 00005: val_acc did not improve from 0.92597
Epoch 6/200
- 1177s - loss: 0.9449 - acc: 0.5602 - val_loss: 0.9976 - val_acc: 0.9246
Epoch 00006: val_acc did not improve from 0.92597
Epoch 7/200
- 1186s - loss: 0.9070 - acc: 0.5598 - val_loss: 0.9667 - val_acc: 0.9258
Epoch 00007: val_acc did not improve from 0.92597
Epoch 8/200
- 1178s - loss: 0.8541 - acc: 0.5663 - val_loss: 0.9254 - val_acc: 0.9221
Epoch 00008: val_acc did not improve from 0.92597
Epoch 9/200
- 1171s - loss: 0.7859 - acc: 0.5853 - val_loss: 0.8686 - val_acc: 0.9237
Epoch 00009: val_acc did not improve from 0.92597
Epoch 10/200
- 1172s - loss: 0.7161 - acc: 0.6139 - val_loss: 0.8119 - val_acc: 0.9260
Epoch 00010: val_acc did not improve from 0.92597
Epoch 11/200
- 1168s - loss: 0.6500 - acc: 0.6416 - val_loss: 0.7531 - val_acc: 0.9259
Epoch 00011: val_acc did not improve from 0.92597
Epoch 12/200
- 1164s - loss: 0.5967 - acc: 0.6676 - val_loss: 0.7904 - val_acc: 0.9260
Epoch 00012: val_acc did not improve from 0.92597
Epoch 13/200
- 1175s - loss: 0.5608 - acc: 0.6848 - val_loss: 0.7589 - val_acc: 0.9259
Epoch 00013: val_acc did not improve from 0.92597
Epoch 14/200
- 1221s - loss: 0.5377 - acc: 0.6980 - val_loss: 0.7811 - val_acc: 0.9260
Epoch 00014: val_acc did not improve from 0.92597
我的模型如下。我知道内核很大,但这是有目的的,因为数据是以某种方式构造的。
cnn = Sequential()
cnn.add(Conv2D(16, kernel_size=(2, 100), padding='same', data_format="channels_first", input_shape=(1,10, 100)))
cnn.add(LeakyReLU(alpha=0.01))
cnn.add(BatchNormalization())
cnn.add(Conv2D(16, (1, 1)))
cnn.add(LeakyReLU(alpha=0.01))
cnn.add(Conv2D(16, (1, 8)))
cnn.add(Flatten())
rnn = Sequential()
rnn = LSTM(100, return_sequences=False, dropout=0.2)
dense = Sequential()
dense.add(Dense(3, activation='softmax'))
main_input = Input(batch_shape=(512, 1, 1, 10, 100))
model = TimeDistributed(cnn)(main_input)
model = rnn(model)
model = dense(model)
replica = Model(inputs=main_input, outputs=model)
replica.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
答案 0 :(得分:1)
很难回答不知道您的模型的问题。
可能的答案是:
我想模型要最小化的实际指标是损失,因此在优化过程中,您应该跟踪损失并监视其改进。
检查this链接以获取有关如何检查模型的更多信息。
答案 1 :(得分:1)