Hello,
I've been doing binary semantic segmentation on 144x96x3 (rgb) images, with as output either 144x96x1 binary images when using a regression loss or 144x96x2 when using the softmax loss. The final layer of my current network is currently a simple softmax:
layer {
name: "loss"
type: "SoftmaxWithLoss"
bottom: "convc2"
bottom: "labelScaled"
top: "loss"
exclude {
stage: "deploy"
}
}
where the output dimensions of
convc2 and
labelScaled are respectively BATCHx144x96x2 and BATCHx144x96x1.
However, there is a strong class imbalance in my images: 94.5% of the pixels in the entire dataset are from the negative class. I wish to weight the softmax loss in order to even it out. I've been following the instructions from
here and I've tried changing my network head to the following:
layer {
name: "prob"
type: "Softmax"
bottom: "convc2"
top: "prob"
exclude {
stage: "deploy"
}
}
layer {
bottom: "prob"
bottom: "labelScaled"
top: "infoGainLoss"
name: "infoGainLoss"
type: "InfogainLoss"
infogain_loss_param {
source: "/path/to/infogainH.binaryproto"
}
exclude {
stage: "deploy"
}
}
but of course I must be doing something wrong since I get the following error:
Creating layer scale2
Creating Layer scale2
scale2 <- label_label_0_split_0
scale2 -> labelScaled
Setting up scale2
Top shape: 16 1 144 96 (221184)
Memory required for data: 364511232
Creating layer prob
Creating Layer prob
prob <- convc2
prob -> prob
Setting up prob
Top shape: 16 2 144 96 (442368)
Memory required for data: 366280704
Creating layer infoGainLoss
Creating Layer infoGainLoss
infoGainLoss <- prob
infoGainLoss <- label_label_0_split_1
infoGainLoss -> infoGainLoss
Check failed: bottom[1]->height() == 1 (144 vs. 1)
What am I doing wrong? Is it possible to weight the classes for semantic segmentation in caffe? I also cannot change my caffe installation since I am at work and I do not own the server it is installed on.