Trouble adding a second supervision label in a second data layer

63 views
Skip to first unread message

Yi Liu

unread,
Jul 28, 2015, 8:58:02 PM7/28/15
to Caffe Users
I am new to Caffe, and I am having some trouble getting multiple data layers to work.
My network is based on the MNIST lenet one. I want the network to predict two labels, rather than just one.

I have attached my network prototxt and draw_net. visualization into this post.  My trouble is as follows: after I try to feed the "data" member of my second data layer ("mnist_noise") into a SoftmaxWithLoss layer, I get an error:

I0728 17:43:37.761723 24067 layer_factory.hpp:74] Creating layer noise-loss
F0728 17:43:37.761865 24067 softmax_loss_layer.cpp:42] Check failed: outer_num_ * inner_num_ == bottom[1]->count() (64 vs. 50176) 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}.

Here is the python code that I used to set up the lmdb for  the second data layer: it contains a single class label in {0, 1, ... 13}.
datum2 = caffe.proto.caffe_pb2.Datum()
datum2.channels = 1
datum2.height = 1
datum2.width = 1
value = 5
datum2.data = np.reshape(value, (1,1,1)).tobytes()

Do I have to do some kind of conversion before the data in my second data ("mnist_noise") can be used as a class label?

Thank you so much for your help!

mnist_denoise.png
allperturb_train_test.prototxt

Yi Liu

unread,
Jul 28, 2015, 10:40:30 PM7/28/15
to Caffe Users, liu.y...@gmail.com
Also, if anyone has an example where there are multiple sources of supervision from multiple datalayers, I would very much appreciate seeing it or getting any tips!
Thanks again in advance!
Reply all
Reply to author
Forward
0 new messages