input_size = 37
output_size = 45
hidden_layer_size = 3
model = tf.keras.Sequential([
tf.keras.layers.Dense(hidden_layer_size, activation='relu'),
tf.keras.layers.Dense(hidden_layer_size, activation='relu'),
tf.keras.layers.Dense(output_size, activation='linear')
])
model.compile(optimizer='adam', loss='mean_absolute_error', metrics=['MeanAbsoluteError','mse'])
batch_size = 10
max_epochs = 20
callback=tf.keras.callbacks.EarlyStopping(patience=2)
model.fit(train_inputs,
train_targets,
batch_size=10,
epochs=max_epochs,
verbose=0,
callbacks=[callback],
validation_data=(validation_inputs, validation_targets)
)
退出:<tensorflow.python.keras.callbacks.History at 0x25bad7cff48>
在::test_loss= model.evaluate(test_inputs, test_targets)
退出: 2/2 [==============================] - 0s 1ms/sample - loss: 0.5252 - mean_absolute_error: 0.5252 - mean_squared_error: 0.6234
答案 0 :(得分:0)
您应该在model.fit()中传递verbose = 2以获得每个时期的结果。 MAE和MSE值取决于您的数据。 MSE对较大的误差值更为敏感,通常,较高的MSE意味着您可能会为少数几个样本获得较大的误差,而较高的MAE意味着您的误差值为较小,但对于许多样本而言,都是较小的误差。