0
我正在尝试使用LSTM来训练一个简单的多对一RNN分类器。我的时间步长为100个数据点,具有7个特征,总共有192382个样本。这是我的型号:多对一的LSTM,Keras上的softmax尺寸错误
model = Sequential()
model.add(LSTM(50,input_shape = (100,7),name = 'LSTM',return_sequences=False))
model.add(Dropout(0.2))
model.add(Dense(3, activation='softmax',name = 'softmax_layer'))
model.compile(optimizer='adam',loss='categorical_crossentropy',metrics=['accuracy'],name='softmax')
model.fit(datax,datay,epochs=25,batch_size=128)
model.summary()
该模型编译罚款没有错误,但我不能适应模型。这是它返回的错误:
ValueError: Error when checking target: expected softmax_layer to have shape (None, 3) but got array with shape (192282, 100)
有没有人有一个想法,为什么softmax图层返回一个(192282,100)矩阵? LSTM层中的return_sequence = False是否应该只给每个时间步输出一个输出?
假设你正在分类至3班,你传递DATAY错误的值 – ilan