我已经构建了一个通用的 Unet 来使用 Keras 训练我自己的数据集。我已将 EarlyStopping 选项设置如下。但是,在训练过程中,它一直提示精度值没有变化,但在下一行,它显然在变化。有没有人遇到过这个问题或知道如何解决这个问题?
train_iterator = create_one_shot_iterator(train_files, batch_size=train_batch_size, num_epoch=epochs)
train_images, train_masks = train_iterator.get_next()
train_images, train_masks = augment_dataset(train_images, train_masks,
augment=True,
resize=True,
scale=1 / 255.,
hue_delta=0.1,
horizontal_flip=True,
width_shift_range=0.1,
height_shift_range=0.1,
rotate=15)
val_iterator = create_initializable_iterator(val_files, batch_size=val_batch_size)
val_images, val_masks = val_iterator.get_next()
val_images, val_masks = augment_dataset(val_images, val_masks,
augment=True,
resize=True,
scale=1 / 255.,
)
model_input = tf.keras.layers.Input(tensor=train_images)
model_output = Unet.u_net_256(model_input)
# Model definition
model = models.Model(inputs=model_input, outputs=model_output)
precision = tf.keras.metrics.Precision()
model.compile(optimizer='adam',
loss=bce_dice_loss,
metrics=[precision],
target_tensors=[train_masks])
model.summary()
cp = [tf.keras.callbacks.ModelCheckpoint(filepath=os.path.join(hdf5_dir, class_name) + '.hdf5',
monitor='val_precision',
save_best_only=True,
verbose=1),
tf.keras.callbacks.TensorBoard(log_dir=log_dir,
write_graph=True,
wr`enter code here`ite_images=True),
tf.keras.callbacks.EarlyStopping(monitor='val_precision', patience=10, verbose=2, mode='max')]
History = model.fit(train_images, train_masks,
steps_per_epoch=int(np.ceil(num_train_samples / float(train_batch_size))),
epochs=epochs,
validation_data=(val_images, val_masks),
validation_steps=int(np.ceil(num_val_samples / float(val_batch_size))),
callbacks=cp,
)