1
$\begingroup$

I am using Keras functional API to write an LSTM model but It throwing an error can somebody please help below is the code for the model the output shape is 65. I am using Keras 2.2.4 and TensorFlow 1.15

event_num = 65
droprate = 0.3
vector_size = 572

def DNN():
    train_input=Input(shape=(vector_size*2,),name='Inputlayer')
    train_in=LSTM(512)(train_input)
    # train_in=BatchNormalization()(train_in)
    train_in=Dropout(droprate)(train_in)
    train_in=LSTM(256)(train_in)
    # train_in=BatchNormalization()(train_in)
    train_in=Dropout(droprate)(train_in)
    train_in=Flatten()(train_in)
    train_in=Dense(event_num)(train_in)
    out=Activation('softmax')(train_in)
    model=Model(input=train_input,output=out)
    model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
    return model

Code Error

$\endgroup$

1 Answer 1

0
$\begingroup$

Your post is a duplicate : Here someone asked the same question.

Have a look at the answers, you can also try this link that gives a detailled explanation about how to reshape inputs for LSTM layers.

$\endgroup$

Your Answer

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

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