keraslstm

keras lstm input shape error pleas help :(


hi i`m trying to create lstm for predict value :(

but my limitation of understand for using keras dimension i think

i need help

my code belows


train_data

train = train.to_numpy()
train = train.reshape(train.shape[0], 1, train.shape[2])
target_load = target_load.iloc[:].values

np.shape(train), np.shape(target_load)

dataShapes for train and answer

from keras import optimizers
from keras.models import Model, Sequential
from keras.layers import Input, Dense, LSTM, Bidirectional, Dropout

xInput = Input(shape=(1,7))
xLstm_1 = LSTM(128, return_sequences=True)(xInput) 
xLstm_1 = Dropout(0.2)(xLstm_1)
xLstm_2 = Bidirectional(LSTM(128))(xLstm_1)
xOutput = Dense(1)(xLstm_2)

ada = optimizers.Adam(lr=0.001)

model = Model(train, target_load)
model.compile(loss='mean_squared_error', optimizer=ada)

model.summary()

errors


Solution

  • Check TensorFlow's API: https://www.tensorflow.org/api_docs/python/tf/keras/Model

    Model objects must be instantiated using symbolic tensors:

    tf.keras.Model(inputs=inputs, outputs=outputs)
    

    In your case that is:

    model = Model(inputs = xInput, outputs = xOutput)