1 year ago
#73809
AnonRocketman
Tensorflow - LSTM RNN overfitting more on Dropout
I have developed a LSTM and applied a dropout rate of 0.2
to all layers (including input).
The model has massive overfitting, meaning that its performance on the training sets increases while the performance on the test set gets worse.
When I disable the dropout the model overfits significantly less.
For Scalling iam using a MinMaxScaler()
, my RNN is a multivariate RNN which evaluates stock prices and various factors, financial metrics.
I use a training share of 80%, (The first 80% of the Data is the trainingsdate and the last 20% of all periods is the test data). It may be important that there are stocks that tend to overfit while others do not produce overfitting.
I also tried the model on another data set. Here the model with a dropout is also overfitted. Can this be taken as an indication that the noise in the data is not the reason for the overfitting? What could be the reasons that a model with dropout has more overfitting? What are possible ways to fix this? Any help is much appreciated!
# Input Layer
lstm1 = LSTM(n_neurons, return_sequences=True)(inp)
# Dropout gets applied to the input Layer
drop1 = Dropout(0.2)(lstm1)
# First Layer
lstm2 = LSTM(n_neurons, return_sequences=True)(drop1)
# Dropout gets applied to the first LSTM Layer
drop2 = Dropout(0.2)(lstm2)
# Second Layer
lstm3 = LSTM(n_neurons, return_sequences=True)(drop2)
# Dropout gets applied to the second LSTM Layer
drop3 = Dropout(0.2)(lstm3)
# Third Layer
lstm4 = LSTM(n_neurons, return_sequences=False)(drop3)
# Droput gets applied to the third LSTM Layer
drop4 = Dropout(0.2)(lstm4)
# Dense One
dense1 = Dense(7)(drop4)
# Dense Two
dense2 = Dense(1)(dense1)
# model.add(Dense(1))
out = dense2
Data example
0 2016-07-05 41.338913 45.472801 ... 7445687.0 56.786912 32.623142
1 2016-07-06 39.389122 40.669456 ... 8014268.0 56.786912 32.623142
2 2016-07-07 39.849373 40.167362 ... 6556726.0 56.786912 32.623142
3 2016-07-08 40.133892 42.351463 ... 5070983.0 56.786912 32.623142
4 2016-07-11 41.179916 42.870293 ... 7220549.0 56.786912 32.623142
... ... ... ... ... ... ...
1357 2021-11-22 79.269997 79.870003 ... 1306800.0 84.553647 21.904104
1358 2021-11-23 78.959999 79.050003 ... 1362600.0 78.252219 23.877031
1359 2021-11-24 77.870003 78.180000 ... 1820300.0 66.012270 22.847237
1360 2021-11-26 76.389999 77.138000 ... 1227200.0 48.612948 22.787207
1361 2021-11-29 76.360001 76.680000 ... 1676000.0 31.332110 24.025858
python
tensorflow
keras
lstm
dropout
0 Answers
Your Answer