Caffe mean file

214 views
Skip to first unread message

Karoly Makonyi

unread,
Jul 29, 2018, 3:35:54 PM7/29/18
to Caffe Users
Hello,

I try to perform a multi-label, multi-class training. I have 4 classes.
I have already packed my data into lmdb (one file for the data (image), one for the label.
I used the caffe/tools/compute_image_mean to extract the mean values from the data-lmdb.

When I run the training I get error:
---
F0729 21:24:46.376538 31882 data_transformer.cpp:66] Check failed: datum_channels == data_mean_.channels() (1 vs. 3)
---

- first question: what should the mean-file contain? (intuitively I expect 3 values (the means of the channles), but browsing the source code (and checking the size of the mean-file) there must be much more ...
- second question: In the data_transformer::transform function I dump the shape of the data_mean_ object and the name of the mean-file:
---
 std::cout << "(mean) " << data_mean_.shape_string() << ' ' << param_.mean_file().c_str() << std::endl;
---

The shape of the data_mean_ is equivalent to the shape of the image-array (in 4D format) and the name of the file that is dumped on the screen is the name of the mean file (as it supposed to be).

What can be the problem? Why I got the error message


I am providing here the data-layer of my prototxt:

----
name: "resultresult"
layer {
  name: "data"
  type: "Data"
  top: "data"
  include {
    phase: TEST
  }
  transform_param {
    scale: 0.003921568859368563
    mean_file: "./mean.binaryproto"
  }
  data_param {
    source: "lamd_data"
    batch_size: 100
    backend: LMDB
  }
}
layer {
  name: "label"
  type: "Data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
    scale: 0.003921568859368563
    mean_file: "./mean.binaryproto"
  }
  data_param {
    source: "lamd_labels"
    batch_size: 100
    backend: LMDB
  }
}
layer {
  name: "data"
  type: "Data"
  top: "data"
  include {
    phase: TRAIN
  }
  transform_param {
    scale: 0.003921568859368563
    mean_file: "./mean.binaryproto"
  }
  data_param {
    source: "lamd_data"
    batch_size: 64
    backend: LMDB
  }
}
layer {
  name: "label"
  type: "Data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    scale: 0.003921568859368563
    mean_file: "./mean.binaryproto"
  }
  data_param {
    source: "lamd_labels"
    batch_size: 64
    backend: LMDB
  }
}



[don't be bothered by the fact that the train and test set is the same. I just want to set up a training procedure ... ]


Every help is appreciated.
Regards,
k,

Przemek D

unread,
Aug 22, 2018, 11:30:26 AM8/22/18
to Caffe Users
It looks like your data is 1-channel (grayscale) but the mean file is (3-channel) RGB. At least that's what the following Transformer error indicates:

data_transformer.cpp:66] Check failed: datum_channels == data_mean_.channels() (1 vs. 3)
It would be useful to see a more complete log - e.g. what size is the data actually, what is the mean shape.

To answer your first question, mean file should be the average taken of all images in your training dataset. The alternative to it is using per-pixel mean, in which case you only need to supply average values for each pixel component (R, G, B) which will then be subtracted from every pixel in every image you put into the network.
Reply all
Reply to author
Forward
0 new messages