Dear Keras users,
I'm trying to implement "Activity Recognition" using CNN and LSTM. When I train my LSTM, the loss of training decreases reasonably, but, for the validation, it does not change.
Log is like this:
Epoch 1/100
3000/3000 [==============================] - 11s - loss: 1.8283 - acc: 0.1883 - val_loss: 1.8100 - val_acc: 0.1726
Epoch 2/100
3000/3000 [==============================] - 10s - loss: 1.7769 - acc: 0.2213 - val_loss: 1.8189 - val_acc: 0.1854
Epoch 3/100
3000/3000 [==============================] - 10s - loss: 1.7488 - acc: 0.2430 - val_loss: 1.8194 - val_acc: 0.1905
Epoch 4/100
3000/3000 [==============================] - 10s - loss: 1.7324 - acc: 0.2553 - val_loss: 1.8168 - val_acc: 0.1777
Epoch 5/100
3000/3000 [==============================] - 10s - loss: 1.7099 - acc: 0.2840 - val_loss: 1.8204 - val_acc: 0.1841
Epoch 6/100
3000/3000 [==============================] - 10s - loss: 1.6925 - acc: 0.2967 - val_loss: 1.8240 - val_acc: 0.1867
Epoch 7/100
3000/3000 [==============================] - 10s - loss: 1.6651 - acc: 0.3237 - val_loss: 1.8353 - val_acc: 0.1777
Epoch 8/100
3000/3000 [==============================] - 10s - loss: 1.6581 - acc: 0.3213 - val_loss: 1.8458 - val_acc: 0.1701
Epoch 9/100
3000/3000 [==============================] - 10s - loss: 1.6390 - acc: 0.3473 - val_loss: 1.8578 - val_acc: 0.1586
Epoch 10/100
3000/3000 [==============================] - 10s - loss: 1.6238 - acc: 0.3577 - val_loss: 1.8446 - val_acc: 0.1944
Epoch 11/100
3000/3000 [==============================] - 10s - loss: 1.6020 - acc: 0.3800 - val_loss: 1.8435 - val_acc: 0.2008
Epoch 12/100
3000/3000 [==============================] - 10s - loss: 1.5945 - acc: 0.3807 - val_loss: 1.8515 - val_acc: 0.1701
Epoch 13/100
3000/3000 [==============================] - 10s - loss: 1.5621 - acc: 0.3990 - val_loss: 1.8521 - val_acc: 0.1931
Epoch 14/100
3000/3000 [==============================] - 10s - loss: 1.5482 - acc: 0.4053 - val_loss: 1.8607 - val_acc: 0.1829
Epoch 15/100
3000/3000 [==============================] - 10s - loss: 1.5243 - acc: 0.4367 - val_loss: 1.8788 - val_acc: 0.1816
Epoch 16/100
3000/3000 [==============================] - 10s - loss: 1.5154 - acc: 0.4410 - val_loss: 1.8903 - val_acc: 0.1662
Epoch 17/100
3000/3000 [==============================] - 10s - loss: 1.4950 - acc: 0.4557 - val_loss: 1.8932 - val_acc: 0.1573
...
...
...
Briefly, from each frame of the clip, I extract CNN features from VGG network (pre-trained on ImageNet) until fc7; so, the length of feature vector for each frame is 2048. For each activity, I use 50 frames.
My LSTM model is:
INPUT_LEN = 50
INPUT_DIM = 4096
OUTPUT_LEN = 6
model = Sequential()
model.add(LSTM(256, input_dim=INPUT_DIM, input_length=INPUT_LEN))
model.add(Dense(OUTPUT_LEN))
model.add(Activation('softmax'))
sgd = SGD(lr=0.001, decay=0.0005, momentum=0.9, nesterov=True)
model.compile(loss='crossentropy', optimizer=sgd, metrics=['accuracy'])
and for the training:
model.fit(X_train, Y_train, batch_size=BATCH_SIZE, nb_epoch=100, validation_data = (X_test, Y_test))
Does anybody have an idea why the training loss and accuracy changes reasonably at each epoch, but, the validation behaviour is crazy?
Thanks