Reputation:
I am getting an error when executing following .prototxt
and I have absolutely no idea why I get an error there:
layer {
name: "conv"
type: "Convolution"
bottom: "image"
top: "conv"
convolution_param {
num_output: 2
kernel_size: 5
pad: 2
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
This is the error output. As I have seen in the latest caffe-master-branch
it should be possible to use 5D-Blobs
.
I1202 14:54:58.617269 2393 hdf5_data_layer.cpp:93] Number of HDF5 files: 9
I1202 14:54:58.631134 2393 hdf5.cpp:35] Datatype class: H5T_INTEGER
I1202 14:54:59.159739 2393 net.cpp:150] Setting up train-data
I1202 14:54:59.159760 2393 net.cpp:157] Top shape: 1 1 1 128 128 (16384)
I1202 14:54:59.159765 2393 net.cpp:157] Top shape: 1 1 8 128 128 (131072)
I1202 14:54:59.159766 2393 net.cpp:165] Memory required for data: 589824
I1202 14:54:59.159773 2393 layer_factory.hpp:77] Creating layer down_level_0_conv
I1202 14:54:59.159790 2393 net.cpp:100] Creating Layer down_level_0_conv
I1202 14:54:59.159795 2393 net.cpp:434] down_level_0_conv <- image
I1202 14:54:59.159804 2393 net.cpp:408] down_level_0_conv -> down_level_0_conv
F1202 14:54:59.159915 2393 blob.hpp:140] Check failed: num_axes() <= 4 (5 vs. 4) Cannot use legacy accessors on Blobs with > 4 axes.
Do I need to go to a certain branch? I just pulled from caffe-master-branch
again to make sure it is the newest version. I then made a make clean make all command and it still does not work.
Upvotes: 3
Views: 676
Reputation: 1608
As a complement of Shai's answer, in order to be compatible with the ND Convolution
and InnerProduct
layer, the "Xavier
" filler code
virtual void Fill(Blob<Dtype>* blob) {
...
int fan_in = blob->count() / blob->num();
int fan_out = blob->count() / blob->channels();
Dtype n = fan_in; // default to fan_in
...
Dtype scale = sqrt(Dtype(3) / n);
caffe_rng_uniform<Dtype>(blob->count(), -scale, scale,
blob->mutable_cpu_data());
CHECK_EQ(this->filler_param_.sparse(), -1)
<< "Sparsity not supported by this Filler.";
}
in caffe, should be more like this:
...
int fan_in = blob->count() / blob->shape(0);
int fan_out = blob->num_axis() == 2 ? blob->shape(0) : blob->count() / blob->shape(1);
...//original stuff
This little change should also make your prototxt work.
Upvotes: 1
Reputation: 114866
AFAIK, this error comes from the "Xavier"
filler: this filler computes the ratio between the input and output channels. If you replace it with a different filler you should be Okay with ND blob.
Upvotes: 2
Reputation:
When I remove the check in line 140 blob.hpp
it does work. This is one way to solve it, not the best one though.
(But this cannot be the proper solution. Is there anything else?)
Upvotes: 0