I am trying to use IoU metrics in a segmentation problem. I just copied the metrics code and pasted into my notebook:
def dice(input:Tensor, targs:Tensor, iou:bool=True)->Rank0Tensor:
"Dice coefficient metric for binary target. If iou=True, returns iou metric, classic for segmentation problems."
n = targs.shape[0]
input = input.argmax(dim=1).view(n,-1)
targs = targs.view(n,-1)
intersect = (input*targs).sum().float()
union = (input+targs).sum().float()
if not iou: return 2. * intersect / union
else: return intersect / (union-intersect+1.0)
I have changed iou=True to get the IoU metrics and passed this as metrics:
metrics = dice
learn = Learner.create_unet(data, models.resnet34, metrics=metrics)
lr_find(learn)
learn.recorder.plot()
The plot is weird and I tried different learning rates (1e-2, 1e-02, etc)
Now, My validation numbers and metrics are all zeros. What am I doing wrong?
epoch train_loss valid_loss dice
1 0.138745 nan 0.000000 (01:17)
2 0.134525 nan 0.000000 (01:15)