Shivam Duggal
Shivam Duggal

Reputation: 317

PyCaffe output layer for testing binary classification model

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.**

Upvotes: 2

Views: 335

Answers (2)

shamitlal_14
shamitlal_14

Reputation: 26

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.

Upvotes: 1

Shai
Shai

Reputation: 114786

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

Upvotes: 1

Related Questions