How does the Softmax Caffe layer calculate probability values?

Does anyone know what kind of calculations happen inside the Softmax Caffe layer?

I use a pre-prepared network with a softmax layer at the end.

In the test phase, for a simple transition of the image, the second-level image ("Internal Product") is as follows: -0.20095, 0.39989, 0.22510, -0.36796, -0.21991, 0.43291, -0.22714, -0.22229, -0.08174, 0.01931, -0.05791, 0.21699 , 0.00437, -0.02350, 0.02924, -0.28733, 0.19157, -0.04191, -0.07360, 0.30252

The output of the last layer ("Softmax") is the following values: 0.00000, 0.44520, 0.01115, 0.00000, 0.00000, 0.89348, 0.00000, 0.00000, 0.00002, 0 , 00015, 0.00003, 0.00940, 0.00011, 0.00006, 0.00018, 0.00000, 0.00550, 0.00004, 0.00002, 0.05710

If I applied Softmax (using an external tool, for example, matlab) at the output of the internal product, I get the following values: 0.0398, 0.0726, 0.0610, 0.0337, 0.0391, 0.0751,

The latter makes sense to me, since probabilities add up to 1.0 (note that the sum of Caffe Softmax level values ​​is> 1.0).

Apparently, the softmax layer in Caffe is not a direct Softmax operation.

(I don't think this makes any sense, but I just mentioned that I am using a pre-prepared flickr-style network, see description here ).

EDIT:

Here is the definition of the last two layers in the prototype. Note that the type of the last layer is “Softmax”.

layer {
  name: "fc8_flickr"
  type: "InnerProduct"
  bottom: "fc7"
  top: "fc8_flickr"
  param {
    lr_mult: 10
    decay_mult: 1
  }
  param {
    lr_mult: 20
    decay_mult: 0
  }
  inner_product_param {
    num_output: 20
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}
layer {
  name: "prob"
  type: "Softmax"
  bottom: "fc8_flickr"
  top: "prob"
}
+4
source share
1 answer

, , . , "Softmax" layer forward:

( , ).

+1

Source: https://habr.com/ru/post/1677342/


All Articles