I am having some problems when I try to load a batch of images + labels within python and try use it to train a network. I am working with pair of images, that I transform into one (for example, by averaging equivalent pixels from both images) and then I feed it to the network. As the number of pairs is too big (combination of the individual images two by two) to store all in memory, I am creating each batch in each iteration and I would like to give it to the network.
I am instantiating the network this way:
solver = caffe.get_solver(path_to_solver_file)
where the input network layers are defined with:
layer {
name: "data"
type: "ImageData"
top: "data"
top: "label"
include {
phase: TRAIN
}
image_data_param {
batch_size: 1
new_height: 227
new_width: 227
}
}
layer {
name: "data"
type: "ImageData"
top: "data"
top: "label"
include {
phase: TEST
}
image_data_param {
batch_size: 1
new_height: 227
new_width: 227
}
}
In my earlier experiments, I had a source parameter inside image_data_param, where I would pass a file with my images and labels for both training and test. However, as I want to load them within python, I removed the source parameter, but got the following error:
0830 17:01:49.014819 1967923200 layer_factory.hpp:77] Creating layer data
I0830 17:01:49.014858 1967923200 net.cpp:91] Creating Layer data
I0830 17:01:49.014868 1967923200 net.cpp:399] data -> data
I0830 17:01:49.014890 1967923200 net.cpp:399] data -> label
I0830 17:01:49.014910 1967923200 image_data_layer.cpp:38] Opening file
I0830 17:01:49.014935 1967923200 image_data_layer.cpp:53] A total of 0 images.
Segmentation fault: 11
I haven't got to this point yet, but after I'm able to instantiate the network, I was going to load the batch and perform one step of the SGD optimization using:
net.blobs["data"].data[...] = images
net.blobs["label"].data[...] = labels
net.step(1)
I have searched for examples and tutorials (for example, here and here) that perform fine-tuning and testing using python, however the great majority only discuss the forward passes during a test phase, whereas the ones that fine-tune a network define the training data (labels and images) using the source parameter, and not by loading directly from the python interface.