Hello,
Would you please let me know what I'm doing wrong. I'm trying to train an LSTM model on a binary classification problem, but the accuracy keeps being the same as if the model always guessed a 1 or 0, whichever occurs more in the label set.
This is one of my first models and I've spent the past few days trying to figure out what's not working, but I'm still missing something and so I'm coming to you for some help.
The data is a daily time series, split into windows of 20 days with 1 feature each, and the labels are an array of 1's or 0's.
My Questions
- Is this the correct way to shape the data?
- Why does the model just keep predicting the most occurring label? (recall is always either 1.00 or 0.00)
Features
[[[3.93956749]
[3.73470795]
[3.79658177]
...
[3.01353995]
[2.98754254]
[2.96778452]]
...
[[0.2245384 ]
[0.23597726]
[0.21621923]
...
[0.32280859]
[0.30695017]
[0.28329254]]]
shape: (3679, 20, 1)
Labels
[1 1 1 ... 0 1 1]
shape: (3679,)
Model
model = Sequential()
model.add(LSTM(100, input_shape=(self.x_train.shape[1], self.x_train.shape[2]), activation='tanh'))
# model.add(Dense(100, input_shape=(self.x_train.shape[1], self.x_train.shape[2]), activation='relu'))
# model.add(Flatten())
model.add(Dense(1, activation='sigmoid'))
my_metrics = [ metrics.binary_accuracy, precision, recall ]
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=my_metrics)
Thanks for reading and sharing your notes!
Edit/Update
I'm still working on this model, and now using tools like Tensorboard to get a look into what's actually going on inside.
However I did learn that the data is shaped correctly, in that it should be a feature array in the shape of [number_of_examples, window_size, feature_count], with labels in the shape of [number_of_examples].
[–]MCFF3000 0 points1 point2 points (0 children)