in SoftmaxLossLayer, check label >= 0 in addition to upper bound
authorJonathan L Long <jonlong@cs.berkeley.edu>
Sat, 22 Nov 2014 19:59:07 +0000 (11:59 -0800)
committerJonathan L Long <jonlong@cs.berkeley.edu>
Sat, 22 Nov 2014 19:59:07 +0000 (11:59 -0800)
src/caffe/layers/softmax_loss_layer.cpp

index 35033b6..c435873 100644 (file)
@@ -44,6 +44,7 @@ void SoftmaxWithLossLayer<Dtype>::Forward_cpu(
   for (int i = 0; i < num; ++i) {
     for (int j = 0; j < spatial_dim; j++) {
       const int label_value = static_cast<int>(label[i * spatial_dim + j]);
+      CHECK_GE(label_value, 0);
       CHECK_GT(dim, label_value * spatial_dim);
       loss -= log(std::max(prob_data[i * dim +
           label_value * spatial_dim + j],