vlfeat / matconvnet

MatConvNet: CNNs for MATLAB
Other
1.4k stars 753 forks source link

Segmentation loss by vl_nnloss() #412

Open luzhi opened 8 years ago

luzhi commented 8 years ago

I did a small experiment that tries to test if I can use vl_nnloss to compute the loss of a segmentation with its ground truth mask. The experiment runs like this:

  1. I take one image from MNIST dataset and manually create a ground truth of this image by thresholding.
  2. Similarly, I manually create a "segmentation" with random numbers as scores for each pixel.
  3. I call the vl_nnloss function to compute the segmentation loss by Y = vl_nnloss(impredict, imgt), where "impredict" is a H x W image of segmentation with single type and "imgt" is the single type ground truth, where 1 represents the pixel belongs to the object and 0 represents the background.

The other parameters are using default, which means "loss" is "softmaxloss" ...

However, the returned Y is a mask of zeros. I tried to debug this function step by step and found the the zeros-mask comes from line 216 to 219, where "ex = exp(bsxfun(@minus, X, Xmax)) ;" I am not sure if my way to compute the segmentation loss is correct or not? Can anyone please advise me on that? Thanks!

liavassif commented 8 years ago

I believe vl_nnloss ignores zero values (they are treated as "don't care") so you should use the values 1 and 2 in your example. You can look at MatConvNet-FCN for image segmentation.