Error [blob.hpp:123] check failed

955 views
Skip to first unread message

dese...@gmail.com

unread,
Sep 23, 2015, 4:48:35 AM9/23/15
to Caffe Users
I make a new net and run. But it showes 'Check failed: axis_index < num_axes() (1 vs. 1) axis 1 out of range for 1-D Blob with shape 64 (64)' when creating layer loss.
I try to fix it and leave my code only  data layer, an ip layer, softmaxwithloss and accuracy layer.But caffe still showes the same wrong message.

I want to know what the axis_index is and why it can be 1.

My codes are as follow:

Solver.prototxt:
net:"/home/usr/anet/anet.prototxt"
#learning
max_iter: 100000
base_lr: 0.01
lr_policy: "step"
gamma: 0.1
stepsize: 5000  
momentum: 0.9
weight_decay: 0.0005
#test
test_iter: 1000
test_interval: 1000
#other
display: 100
snapshot: 10000
snapshot_prefix: "/home/usr/anet"
solver_mode: GPU


Anet.prototxt:
name:"anet"
############ L Data
layer {
  name: "data"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  data_param {
    source:"/home/usr/A_caffe/caffe-master/examples/mnist/mnist_train_lmdb"    #Use this database to try to fix the code
    batch_size: 64          
    backend: LMDB
  }

}
layer {
  name: "data"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  data_param {
    source:"/home/usr/A_caffe/caffe-master/examples/mnist/mnist_test_lmdb"
    batch_size: 20 
    backend: LMDB
  }
}
############ L5
layer {
  type: 'InnerProduct'
  name: 'ip5'
  top: 'ip5'
  bottom: 'data'
  inner_product_param {
    num_output: 10       
    weight_filler { type: 'gaussian' }
  }
}

############ L6 Final
layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "label"
  bottom: "ip5"
  top: "loss"
}
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "ip5"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}

Thanks.

Kevin W Li

unread,
Apr 20, 2016, 4:33:47 PM4/20/16
to Caffe Users
I have the same problem. Have you solved it? 

Jan

unread,
Apr 21, 2016, 4:59:04 AM4/21/16
to Caffe Users
The problem is the following: You need to give the label as the _second_ bottom blob, not the first. The loss and accuracy layers need to make an assumption which blob contains what, because they are not symmetric/interchangeable: Usually the data blob (first bottom blob) contains something like a discrete posterior PDF for every sample, where the label blob (second bottom blob) just contains a single integer number (zero-based class index) for every sample. Switch these two around in your loss layer and everything should work.

Regarding axis_index: It is the zero-based index of the axis in the first bottom blob along which the softmax is computed, or along which the class prediction is computed by argmax, respectively. Usually this is 1, since the first axis (index 0) denotes the sample index in the batch. That being said, it can be set to a different value (using a configuration variable in the layer in the net's prototxt), which can make sense in certain settings. But not in your setting.

Jan

Zhuotun Zhu

unread,
Jul 5, 2016, 12:11:15 PM7/5/16
to Caffe Users
I am stuck in the same problem. Have you solved it? =_=

Zhuotun Zhu

unread,
Jul 5, 2016, 12:34:40 PM7/5/16
to Caffe Users
Hi Kevin, have you solved your problem?

Jianyuan Shi

unread,
Apr 28, 2017, 10:00:25 AM4/28/17
to Caffe Users
Hi,Jan. would you tell me how to solve it in detail? I have try many times to fix it, but fail

在 2016年4月21日星期四 UTC+8下午4:59:04,Jan写道:

Fateh Singh

unread,
Jun 23, 2017, 1:02:07 AM6/23/17
to Caffe Users
Did anyone figure out the reason ? I have the same problem
Reply all
Reply to author
Forward
0 new messages