我对keras比较陌生,所以我玩了一个简单的seq2seq架构 .

model = Sequential()
model.add(Embedding(22, 10, input_length=32, mask_zero=True))
model.add(LSTM(4, return_sequences = True))
model.add(TimeDistributed(Dense(output_dim=3)))
model.add(Activation('softmax'))
model.compile(loss='categorical_crossentropy',
            optimizer='rmsprop',
            metrics=['accuracy'])
model.fit(x,y,nb_epoch =1, batch_size = 1, verbose = 2)

Exception: Error when checking model target: expected activation_6 to have shape (None, 32, 3) but got array with shape (2, 4, 3)

x的形状为(2,32),y的形状为(2,4,3) .

根据我的理解,这意味着y有2个例子,每个序列的长度为4,一个热编码为3维 . 但是,当我运行model.fit时,似乎它不是我期待的形状 . 为什么会这样?