【发布时间】:2021-03-22 05:57:21
【问题描述】:
输入尺寸:
train_ohe :(95036, 50, 21)
y_train :(95036,)
val_ohe :(9911, 50, 21)
y_val :(9911,)
型号:
x_input = Input(shape=(50,))
emb = Embedding(21, 8, input_length=50)(x_input)
bi_rnn = LSTM(50, input_shape=(50,20,50), return_sequences=False)(emb)
x = Dropout(0.3)(bi_rnn)
x_output = Dense(1, activation='relu')(x)
model1 = Model(inputs=x_input, outputs=x_output)
model1.compile(optimizer='adam', loss='mse', metrics=['mse'])
history1 = model1.fit(
train_ohe, y_train,
epochs=1, batch_size=256,validation_data=(val_ohe, y_val),callbacks=[es]
)
注意
Vocab size=20, input_length=50
我尝试将 return_sequences 更改为 True/False,还尝试了 (50, 20)/(50,20,50) 中 LSTM 层的尺寸,但仍然出现相同的错误。
【问题讨论】:
标签: tensorflow keras lstm recurrent-neural-network one-hot-encoding