BVLC / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
34.12k stars 18.69k forks source link

Documentation for SoftmaxWithLoss about label shape #6014

Open dashesy opened 7 years ago

dashesy commented 7 years ago

Issue summary

The documentation for SoftmaxWithLoss is

@param bottom input Blob vector (length 2)

* -# equation

 *      the labels @f$ l @f$, an integer-valued Blob with values

But here in the code this is what is checked:

  CHECK_EQ(outer_num_ * inner_num_, bottom[1]->count())
      << "Number of labels must match number of predictions; "
      << "e.g., if softmax axis == 1 and prediction shape is (N, C, H, W), "
      << "label count (number of labels) must be N*H*W, "
      << "with integer values in {0, 1, ..., C-1}.";

So the documentation should have been:

* -# equation

shaibagon commented 7 years ago

it is a little bit more complicated than that... The label shape depends on the axis parameter as well...

dashesy commented 7 years ago

axis parameter should point to C. The only way that equation could be correct is if axis is -1 (last one). Even then, having C == 1 is not correct.