我正在使用 Keras 函数式 API 编写一个 LSTM 模型,但它抛出了一个错误,有人可以帮忙吗?下面是输出形状为 65 的模型的代码。
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