我正在尝试为回归问题训练神经网络,并且我实现了 Keras 早期停止功能以避免过度拟合。
现在,当我监视“val_loss”时,提前停止功能几乎直接停止程序,结果是一个无用的神经网络,但是当我监视“val_mse”时,训练继续进行而不会停止,尽管我可以看到“val_mse”在整个过程中不断增加训练,我设置耐心= 0。
我似乎误解了早期停止回调,因为我认为它确实会监控值并在值再次开始增加时立即停止训练。
np.random.seed(7)
#Define Input
tf_features_64 = np.load("IN_2.npy")
tf_labels_64 = np.load("OUT_2.npy")
tf_features_32 = tf_features_64.astype(np.float32)
tf_labels_32 = tf_labels_64.astype(np.float32)
X = tf_features_32
Y = tf_labels_32[0:10680, 4:8]
#Define Callback
tbCallBack = TensorBoard(log_dir='./Graph{}', histogram_freq=0, write_graph=True, write_images=True) #TensorBoard Monitoring
esCallback = EarlyStopping(monitor='val_mse',
min_delta=0,
patience=0,
verbose=1,
mode='min')
#create Layers
visible = Input(shape=(33,))
x = Dropout(.1)(visible)
#x = Dense(63)(x)
#x = Dropout(.4)(x)
output = Dense(4)(x)
Optimizer = optimizers.Adam(lr=0.001
#amsgrad = True)
model = Model(inputs=visible, outputs = output)
model.compile(optimizer=Optimizer,
loss=['mse'],
metrics=['mae', 'mse']
)
model.fit(X, …Run Code Online (Sandbox Code Playgroud)