0
$\begingroup$

For a year I've been collecting data from my RPi:

[0 core load, 1 core load, 2 core load, 3 core load, environment temperature, fan speed, CPU temperature]

Now I want to build a model with Keras and LSTMs to make a prediction of core temperature based on a vector [0 core load, 1 core load, 2 core load, 3 core load, environment temperature, fan speed].

The main problem is that I can not compose this data into time series, because I've sorted it by 0 core load unintentionally. So this data can be considered as shuffled.

Current model does not work at all:

model = Sequential()

model.add(Dense(128, activation='relu'))
model.add(Dense(128, activation='relu'))
model.add(Dense(128, activation='relu'))
model.add(Dense(128, activation='relu'))
model.add(LSTM(128))
model.add(LSTM(128))

model.add(Dense(1, activation='sigmoid'))

Training summary:

Epoch 1/128
6483/6483 [==============================] - 45s 7ms/step - loss: 140033.1094 - val_loss: 119426.7812
Epoch 2/128
6483/6483 [==============================] - 45s 7ms/step - loss: 140032.5156 - val_loss: 119426.7812
Epoch 3/128
6483/6483 [==============================] - 45s 7ms/step - loss: 140034.2500 - val_loss: 119426.7812
Epoch 4/128
6483/6483 [==============================] - 45s 7ms/step - loss: 140040.8438 - val_loss: 119426.7812
Epoch 5/128
5071/6483 [======================>.......] - ETA: 9s - loss: 140302.2812

How can I predict such shuffled data with LSTM? I'm currently stuck.

$\endgroup$

1 Answer 1

0
$\begingroup$

The input for an RNN like LSTM should be in the shape of (batch, timestep, features).

Base on my experience, if your current X_train.shape is in 2D you would like to reshape it into 3D array by X_train = np.reshape(X_train, (X_train.shape[0], X_train.shape[1], 1)) Then It will be something like (total number of samples, 7,1); 7 is because you have 7 different features.

By the way, you probably would like to start with a single layer of Dense and LSTM.

Further, using multiple layers of LSTM would require you to set return_sequences to True for all LSTM layers before the last one

model.add(LSTM(128,return_sequences = True))
model.add(LSTM(128))
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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