I set up a model in keras (in python 2.7) to predict the next stock price in a particular sequence.

The model I used is shown below (edited to fit this page):

model = Sequential()
model.add(Dense(5, input_shape=(1, 1)))
model.add(LSTM(5, return_sequences=True))
model.compile(loss="mse", optimizer="Nadam", metrics=["mape"])
predict = model.fit(X, Y, epochs=epochs, verbose=1, validation_split=0.2,
                    callbacks=[checkpoint_maker], shuffle=True,
                    batch_size=count / 10 * 8)

However, when I ran the model, I found that val_mean_absolute_percentage_error decreases while the mean_absolute_percentage_error increases.

Here is the graph I managed to generate after 1000 epochs. Graph

Notice that the blue line is going up while the orange line is going down.

I have no idea why.

I've read on some sources that if the loss is decreasing and the val_loss is increasing it means that:

(the) model is over fitting, that (it) is just memorizing the training data - https://stats.stackexchange.com/a/260346

So does that mean, that in my case, the model is "under fitting"?

P.S. Code and files


Although a bit late, I had a similar problem. In my case, the problem was my data generator. I added noise to an image in the form of randomly chosen columns. However, the generator accumulated the noise. Each epoch contained more and more noise.

I only used this data augmentation on the training data.

If you see something similar, check your generator.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.