[英]while I was trying to train a DeepSpeech model on google colab, I'm getting an error saying that .whl file is not suported
[英]I'm trying to train the model using keras library but I'm getting value error
model = tf.keras.Sequential()
model.add(layers.Embedding(input_dim=2954, output_dim=64))
model.add(layers.LSTM(128))
model.add(layers.Dense(10))
model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])
model.summary()
ValueError:一個形狀為 (1, 2954) 的目標數組被傳遞給形狀 (None, 10) 的輸出,同時用作損失 categorical_crossentropy。 此損失期望目標與輸出具有相同的形狀。
檢查您的目標/標簽。 您的目標應該是單熱編碼的,因為您使用的是categorical_crossentropy
作為損失函數。 該錯誤抱怨您的目標數組的形狀不是(batch_size, 10)
,而是(1, 2954)
PS最后一個Dense
層應該有一個 softmax 激活函數:
model.add(layers.Dense(10, activation='softmax'))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.