Error in loss layer "Inputs must have the same dimension"

22 views
Skip to first unread message

Sultana Tania

unread,
May 17, 2018, 4:50:17 AM5/17/18
to Caffe Users
I0517 17:20:57.718914  4852 layer_factory.hpp:77] Creating layer data
I0517 17:20:57.718928  4852 net.cpp:94] Creating Layer data
I0517 17:20:57.718935  4852 net.cpp:409] data -> data
I0517 17:20:57.718951  4852 net.cpp:409] data -> label
I0517 17:20:57.718967  4852 hdf5_data_layer.cpp:79] Loading list of HDF5 filenames from: /mnt/lab-raid2/home/A/train.txt
I0517 17:20:57.720168  4852 hdf5_data_layer.cpp:93] Number of HDF5 files: 1
I0517 17:20:57.722488  4852 hdf5.cpp:32] Datatype class: H5T_FLOAT
I0517 17:20:57.730764  4852 net.cpp:144] Setting up data
I0517 17:20:57.730803  4852 net.cpp:151] Top shape: 22 1 33 33 (23958)
I0517 17:20:57.730808  4852 net.cpp:151] Top shape: 22 1 21 21 (9702)
I0517 17:20:57.730810  4852 net.cpp:159] Memory required for data: 134640
I0517 17:20:57.730818  4852 layer_factory.hpp:77] Creating layer conv1
I0517 17:20:57.730851  4852 net.cpp:94] Creating Layer conv1
I0517 17:20:57.730856  4852 net.cpp:435] conv1 <- data
I0517 17:20:57.730871  4852 net.cpp:409] conv1 -> conv1
I0517 17:20:57.738759  4852 net.cpp:144] Setting up conv1
I0517 17:20:57.738811  4852 net.cpp:151] Top shape: 22 96 29 29 (1776192)
I0517 17:20:57.738821  4852 net.cpp:159] Memory required for data: 7239408
I0517 17:20:57.738858  4852 layer_factory.hpp:77] Creating layer relu1
I0517 17:20:57.738883  4852 net.cpp:94] Creating Layer relu1
I0517 17:20:57.738893  4852 net.cpp:435] relu1 <- conv1
I0517 17:20:57.738907  4852 net.cpp:396] relu1 -> conv1 (in-place)
I0517 17:20:57.738943  4852 net.cpp:144] Setting up relu1
I0517 17:20:57.738957  4852 net.cpp:151] Top shape: 22 96 29 29 (1776192)
I0517 17:20:57.738966  4852 net.cpp:159] Memory required for data: 14344176
I0517 17:20:57.738976  4852 layer_factory.hpp:77] Creating layer conv2
I0517 17:20:57.739048  4852 net.cpp:94] Creating Layer conv2
I0517 17:20:57.739058  4852 net.cpp:435] conv2 <- conv1
I0517 17:20:57.739074  4852 net.cpp:409] conv2 -> conv2
I0517 17:20:57.742362  4852 net.cpp:144] Setting up conv2
I0517 17:20:57.742391  4852 net.cpp:151] Top shape: 22 24 29 29 (444048)
I0517 17:20:57.742401  4852 net.cpp:159] Memory required for data: 16120368
I0517 17:20:57.742421  4852 layer_factory.hpp:77] Creating layer relu2
I0517 17:20:57.742439  4852 net.cpp:94] Creating Layer relu2
I0517 17:20:57.742449  4852 net.cpp:435] relu2 <- conv2
I0517 17:20:57.742465  4852 net.cpp:396] relu2 -> conv2 (in-place)
I0517 17:20:57.742483  4852 net.cpp:144] Setting up relu2
I0517 17:20:57.742494  4852 net.cpp:151] Top shape: 22 24 29 29 (444048)
I0517 17:20:57.742502  4852 net.cpp:159] Memory required for data: 17896560
I0517 17:20:57.742512  4852 layer_factory.hpp:77] Creating layer conv3
I0517 17:20:57.742532  4852 net.cpp:94] Creating Layer conv3
I0517 17:20:57.742540  4852 net.cpp:435] conv3 <- conv2
I0517 17:20:57.742554  4852 net.cpp:409] conv3 -> conv3
I0517 17:20:57.747347  4852 net.cpp:144] Setting up conv3
I0517 17:20:57.747378  4852 net.cpp:151] Top shape: 22 1 29 29 (18502)
I0517 17:20:57.747387  4852 net.cpp:159] Memory required for data: 17970568
I0517 17:20:57.747408  4852 layer_factory.hpp:77] Creating layer loss
I0517 17:20:57.747427  4852 net.cpp:94] Creating Layer loss
I0517 17:20:57.747437  4852 net.cpp:435] loss <- conv3
I0517 17:20:57.747448  4852 net.cpp:435] loss <- label
I0517 17:20:57.747462  4852 net.cpp:409] loss -> loss
F0517 17:20:57.747512  4852 euclidean_loss_layer.cpp:12] Check failed: bottom[0]->count(1) == bottom[1]->count(1) (841 vs. 441) Inputs must have the same dimension.
*** Check failure stack trace: ***
    @     0x2af492d685cd  google::LogMessage::Fail()
    @     0x2af492d6a433  google::LogMessage::SendToLog()
    @     0x2af492d6815b  google::LogMessage::Flush()
    @     0x2af492d6ae1e  google::LogMessageFatal::~LogMessageFatal()
    @     0x2af49213fe52  caffe::EuclideanLossLayer<>::Reshape()
    @     0x2af4922618f6  caffe::Net<>::Init()
    @     0x2af4922631c6  caffe::Net<>::Net()
    @     0x2af492243cca  caffe::Solver<>::InitTrainNet()
    @     0x2af4922450d7  caffe::Solver<>::Init()
    @     0x2af492245493  caffe::Solver<>::Solver()
    @     0x2af4922ce4b5  caffe::Creator_SGDSolver<>()
    @           0x40b9a5  train()
    @           0x408668  main
    @     0x2af4941a7830  __libc_start_main
    @           0x408dd9  _start
    @              (nil)  (unknown)


How do I solve this problem?How do I fixed the same dimension?Here I add the network.I use HDF5D in matlab.
net.prototxt.docx

Przemek D

unread,
Aug 20, 2018, 8:45:04 AM8/20/18
to Caffe Users
Euclidean Loss matches its first input blob to the second blob, calculating an L2 distance between them. Those blobs need to have the exact same size, e.g. if you have 22x1x21x21 "label" blob (size after flattening: 22x441) you also need the "data" blob to be 22x441 after flattening. In your case it is larger: 22x1x29x29, which gives 22x841 - hence the error. The solution would be to modify the network so that the final output size matched the label.
Reply all
Reply to author
Forward
0 new messages