-
Notifications
You must be signed in to change notification settings - Fork 3
/
Training Segmentation Model.py
28 lines (28 loc) · 1.13 KB
/
Training Segmentation Model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
adam = tf.keras.optimizers.Adam(lr = 0.05, epsilon = 0.1)
seg_model.compile(optimizer = adam,
loss = focal_tversky,
metrics = [tversky]
)
#callbacks
earlystopping = EarlyStopping(monitor='val_loss',
mode='min',
verbose=1,
patience=20
)
# save the best model with lower validation loss
checkpointer = ModelCheckpoint(filepath="ResUNet-segModel-weights.hdf5",
verbose=1,
save_best_only=True
)
reduce_lr = ReduceLROnPlateau(monitor='val_loss',
mode='min',
verbose=1,
patience=10,
min_delta=0.0001,
factor=0.2
)
h = seg_model.fit(train_data,
epochs = 60,
validation_data = val_data,
callbacks = [checkpointer, earlystopping, reduce_lr]
)