Doodleverse / segmentation_gym

A neural gym for training deep learning models to carry out geoscientific image segmentation. Works best with labels generated using https://github.com/Doodleverse/dash_doodler
MIT License
45 stars 11 forks source link

K-L metric or loss #35

Closed dbuscombe-usgs closed 3 years ago

dbuscombe-usgs commented 3 years ago

it makes sense to explore K-L distance as a loss function or metric, see:

https://github.com/dbuscombe-usgs/segmentation_zoo/issues/32#issuecomment-966740690

dbuscombe-usgs commented 3 years ago

plotcomp_n_getiou now computes and reports K-L divergence for each validation and train pair tested in train_model.py

hatteras_l8_resunet_val_15

hatteras_l8_resunet_val_52

smaller values of KLD are better (smaller divergence)

D_vs_KL

Hatteras stats now:

Evaluating model on entire validation set ...
15/15 [==============================] - 2s 164ms/step - loss: 0.0222 - mean_iou: 0.9839 - dice_coef: 0.9778
loss=0.0222, Mean IOU=0.9839, Mean Dice=0.9778
Mean of mean IoUs (validation subset)=0.983
Mean of mean Dice scores (validation subset)=0.977
Mean of mean KLD scores (train subset)=0.142
Mean of mean IoUs (train subset)=0.988
Mean of mean Dice scores (train subset)=0.982
Mean of mean KLD scores (train subset)=0.100

also added KLD as a model training option

elif LOSS.startswith('k'):
    model.compile(optimizer = 'adam', loss =tf.keras.losses.KLDivergence(), metrics = [mean_iou, dice_coef])
dbuscombe-usgs commented 3 years ago

needs:

dbuscombe-usgs commented 3 years ago

trained resunet model with Kullback–Leibler on the Klamath L8 C/T imagery with 80% validation split and 0.2 dropout

As I suspected, the unet does converge easily and quickly

ct_E_resunet_allclasses_512_remap_trainhist_8

outputs are good, comparable to dice loss

perhaps it is a good loss function for a Unet when you want to preserve the overall frequency distribution of classes in model predictions?

dbuscombe-usgs commented 3 years ago

tested, docs updated. closing