1

I have built a common Unet to train my own dataset by using Keras. I have set the EarlyStopping option as follows. However, during training, it keeps prompt out the precision value dis not change but in the next line, it is apparently changing. Has anyone meet this problem before or know how to solve the problem?

enter image description here

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,
                    )
M. Dai
  • 11
  • 1
  • Sorry your question was hard to understand because you did not enter a description of the image you linked showing your output. Instead it is labeled as "enter image description here." – brethvoice May 19 '21 at 19:21

1 Answers1

0

The feedback message you are getting is letting you know that for the epoch just completed, no improvement in validation precision occurred. This is probably happening because you have set verbose=2 in the callback settings, which is intended to give you a heads up that if you see the message for 10 consecutive epochs, your training will end.

brethvoice
  • 350
  • 1
  • 4
  • 14