0

注釈付きテキストから単語に関連付けられたラベルを見つけようとしています。を使用していbidirectional LSTMます。X_train形状(1676, 39)Y_train同じ形状(1676, 39) があります。

input = Input(shape=(sequence_length,))
model = Embedding(input_dim=n_words, output_dim=20,
              input_length=sequence_length, mask_zero=True)(input)
model = Bidirectional(LSTM(units=50, return_sequences=True,
                       recurrent_dropout=0.1))(model)
out_model = TimeDistributed(Dense(50, activation="softmax"))(model) 
model = Model(input, out_model)
model.compile(optimizer="rmsprop", loss= "categorical_crossentropy", metrics=["accuracy"])
model.fit(X_train, Y_train, batch_size=32, epochs= 10,
                validation_split=0.1)

これを実行すると、エラーが発生します:

ValueError: Error when checking target: expected time_distributed_5 to have 3 dimensions, but got array with shape (1676, 39).

Keras LSTM モデルに必要な適切な次元を供給する方法を見つけることができません。

4

1 に答える 1