Skip to content

Commit

Permalink
fix wrong check, remove type conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Payer committed Apr 13, 2016
1 parent 0764a59 commit 913d46c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions include/caffe/filler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,19 @@ class LinearFiller : public Filler<Dtype> {
explicit LinearFiller(const FillerParameter& param)
: Filler<Dtype>(param) {}
virtual void Fill(Blob<Dtype>* blob) {
CHECK_GT(blob->num_axes(), 3) << "Blob must have at least 3 dimensions.";
CHECK_GE(blob->num_axes(), 3) << "Blob must have at least 3 dimensions.";
Dtype* data = blob->mutable_cpu_data();
for (int i = 0; i < blob->count(); ++i) {
unsigned int stride = 1;
Dtype weight = 1;
for (int axis = 0; axis < blob->num_axes() - 2; ++axis) {
unsigned int shape = blob->shape(axis + 2);
unsigned int sampling_factor = std::ceil(shape / 2.0f);
float center = (2 * sampling_factor - 1 - sampling_factor % 2)
/ (2.0f * sampling_factor);
float coordinate = (i / stride) % shape;
weight *= 1 - std::abs(coordinate / sampling_factor - center);
unsigned int factor = std::ceil(shape / 2.0f);
Dtype center = (2 * factor - 1 - factor % 2)
/ static_cast<Dtype>(2 * factor);
Dtype coordinate = ((i / stride) % shape)
/ static_cast<Dtype>(factor);
weight *= 1 - std::abs(coordinate - center);
stride *= shape;
}
data[i] = weight;
Expand Down

0 comments on commit 913d46c

Please sign in to comment.