X
X
Xvir432019-12-23 11:03:20
Python
Xvir43, 2019-12-23 11:03:20

How to properly form kerasa lstm?

Tell me how to correctly build a grid model
like this I collect a sample and a model

def create_dataset(dataset, look_back, out_n):
    dataX, dataY = [], []
    for i in range(len(dataset)-look_back-out_n):
        dataX.append(dataset[i:(i+look_back)]) 
        dataY.append(dataset[i+look_back:(i+look_back+out_n) , 0:1]) 
    return np.array(dataX), np.array(dataY)

input_n = 48
out_n=24
print(dX.shape, dY.shape) #(1927, 48, 6) (1927, 24, 1)

model = Sequential()
model.add(LSTM(128, input_shape=(dX.shape[1], dX.shape[2]),return_sequences=True))
model.add(Dense(dY.shape[1]))

ValueError: Error when checking target: expected dense_47 to have shape (48, 24) but got array with shape (24, 1
)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
deeppsycoder, 2020-01-02
@deeppsycoder

Option 1: return_sequences=False.
Option 2: model.add(GlobalMaxPool1D()) between LSTM and Dense.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question