2

I fine tunes vgg-16 for binary classification. I used sigmoidLoss layer as the loss function.

To test the model, I coded a python file in which I loaded the model with an image and got the output using :

out = net.forward()

My doubt is should I take the output from Sigmoid or SigmoidLoss layer. And What is the difference between 2 layers.

My output will actually be the probability of input image being class 1.**

Shivam Duggal
  • 317
  • 2
  • 10

2 Answers2

1

SigmoidWithLoss layer outputs a single number per batch representing the loss w.r.t the ground truth labels.

On the other hand, Sigmoid layer outputs a probability value for each input in the batch. This output does not require the ground truth labels to be computed.

If you are looking for the probability per input, you should be looking at the output of the Sigmoid layer

Shai
  • 111,146
  • 38
  • 238
  • 371
  • what does SigmoidWithLoss layer's output represents during testing, since there is no ground-truth label. – Shivam Duggal Mar 19 '17 at 11:14
  • @ShivamDuggal see [this answer](http://stackoverflow.com/a/39018076/1714410). You cannot have `"SigmoidCrossEntropyLoss"` layer without ground truth. the layer **must** have two inputs. – Shai Mar 19 '17 at 11:17
1

For making predictions on test set, you can create a separate deploy prototxt by modifying the original prototxt.

Following are the steps for the same

  • Remove the data layer that was used for training, as for in the case of classification we are no longer providing labels for our data.
  • Remove any layer that is dependent upon data labels.
  • Set the network up to accept data.
  • Have the network output the result.

You can read more about this here: deploy prototxt

Else, you can add
include { phase: TRAIN }

to your SigmoidWithLoss layer so that it's not used when testing the network. To make predictions, simply check the output of Sigmoid layer.