Reputation: 893
I followed the Caffe ImageNet Tutorial and could successfully train the bvlc_reference_caffenet. Now I would like to scale the input data from [0,255] to [0,1] (since I later have to run this CNN on hardware with limited fixed/floating point accuracy) like in the Caffe LeNet MNIST Tutorial where it is done by adding a scale
parameter to the data
layer:
layer {
name: "mnist"
type: "Data"
transform_param {
scale: 0.00390625
}
data_param {
source: "mnist_train_lmdb"
backend: LMDB
batch_size: 64
}
top: "data"
top: "label"
}
Due to this I added this scale parameter also to the bvlc_reference_caffenet and also divide the mean parameter which will be subtracted from each channel by 255:
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
crop_size: 227
scale: 0.00390625
mean_value: 0.40784313
mean_value: 0.45882352
mean_value: 0.48235294
mirror: true
}
data_param {
source: "examples/imagenet/ilsvrc12_train_lmdb"
batch_size: 32
backend: LMDB
}
}
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TEST
}
transform_param {
crop_size: 227
scale: 0.00390625
mean_value: 0.40784313
mean_value: 0.45882352
mean_value: 0.48235294
mirror: false
}
data_param {
source: "examples/imagenet/ilsvrc12_val_lmdb"
batch_size: 32
backend: LMDB
}
}
When I train the net now the accuracy will always be lower than chance. What other parameters do I have to adopt to train the net with [0,1] images instead of [0,255] images?
Upvotes: 2
Views: 87
Reputation: 5522
Caffe first subtracts the mean and then scales the result. You should retain your original 0...255
mean values.
Reference:
if (has_mean_file) {
transformed_data[top_index] =
(datum_element - mean[data_index]) * scale;
}
Upvotes: 3