简体   繁体   English

在keras中的每个纪元后如何查看验证错误

[英]How to see the validation error after each epoch in keras

I am using keras to train a model for regression. 我正在使用keras训练回归模型。 My code looks like: 我的代码如下:

estimators = []
estimators.append(('standardize', StandardScaler()))
estimators.append(('mlp', KerasRegressor(build_fn=baseline_model, epochs=100, batch_size=32, verbose=2)))
pipeline = Pipeline(estimators)
X_train, X_test, y_train, y_test = train_test_split(X, Y,
                                                    train_size=0.75, test_size=0.25)
pipeline.fit(X_train, y_train)

The problem is that it is dramatically overfitting. 问题在于它过度拟合。 How can I see the validation error after each epoch? 在每个时期之后如何查看验证错误?

You can transmit parameters to KerasRegressor fit method: 您可以将参数传输到KerasRegressor fit方法:

validation_split: float (0. < x < 1). validation_split:浮点型(0. <x <1)。 Fraction of the data to use as held-out validation data. 用作保留验证数据的数据分数。 validation_data: tuple (x_val, y_val) or tuple (x_val, y_val, val_sample_weights) to be used as held-out validation data. validation_data:用作保留验证数据的元组(x_val,y_val)或元组(x_val,y_val,val_sample_weights)。 Will override validation_split. 将覆盖validation_split。

via Pipeline fit method : 通过管道拟合方法

**fit_params : dict of string -> object Parameters passed to the fit method of each step, where each parameter name is prefixed such that parameter p for step s has key s__p. ** fit_params:字符串->对象的字典传递给每个步骤的fit方法的参数,其中每个参数名称都带有前缀,以便步骤s的参数p具有键s__p。

Example: 例:

pipeline.fit(X_train, y_train, mlp__validation_split=0.3)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM