dusa
dusa

Reputation: 820

How do I get the weighted sum of multiple losses & accuracy (caffe)

I have trained a network on two different modals of the same image. I pass the data together in one layer but after that, it is pretty much two networks in parallel, they don't share a layer and the two tasks have different set of labels, therefore I have two different loss and accuracy layers.

  1. I have read that caffe averages multiple losses and accuracy (following this question How can I have multiple losses in a network in Caffe?), is it the case only when at least a layer is shared? I intended to create an ensemble, however now it seems like I simply have two different networks. I intended to average the losses & accuracy so that both network branches would contribute to one accuracy. On training I see two separate losses & accuracy. How do I get this average loss & accuracy while testing on a new image pair?

  2. By forwarding the network, is it possible to get two predictions at all? If so, how?

Upvotes: 0

Views: 568

Answers (1)

Jayant Agrawal
Jayant Agrawal

Reputation: 779

Multiple Losses can be used with one network using the caffe-parameter loss_weight. For example, you can have the following for one of your loss layers with weight 0.5 .

...
layer{
  name: "loss_a"
  type: "SigmoidCrossEntropyLoss"
  bottom: "fc8_a"
  bottom: "attributes_a"
  top : "loss_a"
  loss_weight : 0.5
 }

 layer{
  name: "loss_b"
  type: "SigmoidCrossEntropyLoss"
  bottom: "fc8_b"
  bottom: "attributes_b"
  top : "loss_b"
}

Upvotes: 2

Related Questions