不知道什么问题,明明不是多输出的网络,出现错误ValueError: All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.
model = tf.keras.models.Sequential([
layers.Bidirectional(layers.LSTM(units=100,activation=‘tanh’, return_sequences=True, return_state=True, input_shape=(1, 50))),
layers.Bidirectional(layers.LSTM(units=100,activation=‘tanh’, return_sequences=True, return_state=True)),
layers.Bidirectional(layers.LSTM(units=100,activation=‘tanh’, return_sequences=True, return_state=False)),
layers.Dense(units=100,activation=‘tanh’),
layers.Dropout(0.1),
layers.Dense(units=100,activation=‘tanh’),
layers.Dense(50)
])
model.compile(optimizer=keras.optimizers.Adam(1e-4),
loss=tf.keras.losses.mean_squared_error,
metrics=[‘mse’])
num_epochs = 20#对完整训练数据迭代的次数
history = model.fit(train_input,train_output, epochs=num_epochs,validation_split=0.1)
model.evaluate(test_input,test_output)
@snowkylin