Skip to content

Commit

Permalink
Merge pull request BVLC#3913 from antran89/master
Browse files Browse the repository at this point in the history
minor fix to stochastic pooling and clean-up of mean computation
  • Loading branch information
shelhamer authored Apr 14, 2017
2 parents 2cbc1bb + 6382d67 commit c11e782
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/caffe/layers/pooling_layer.cu
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ __global__ void StoPoolForwardTest(const int nthreads,
const int wstart = pw * stride_w;
const int wend = min(wstart + kernel_w, width);
// We set cumsum to be 0 to avoid divide-by-zero problems
Dtype cumsum = FLT_MIN;
Dtype cumsum = 0.;
Dtype cumvalues = 0.;
const Dtype* const bottom_slice =
bottom_data + (n * channels + c) * height * width;
Expand All @@ -149,7 +149,7 @@ __global__ void StoPoolForwardTest(const int nthreads,
cumvalues += bottom_slice[h * width + w] * bottom_slice[h * width + w];
}
}
top_data[index] = cumvalues / cumsum;
top_data[index] = (cumsum > 0.) ? cumvalues / cumsum : 0.;
}
}

Expand Down
8 changes: 5 additions & 3 deletions tools/compute_image_mean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ DEFINE_string(backend, "lmdb",
"The backend {leveldb, lmdb} containing the images");

int main(int argc, char** argv) {
#ifdef USE_OPENCV
::google::InitGoogleLogging(argv[0]);
// Print output to stderr (while still logging)
FLAGS_alsologtostderr = 1;

#ifdef USE_OPENCV
#ifndef GFLAGS_GFLAGS_H_
namespace gflags = google;
#endif
Expand Down Expand Up @@ -65,7 +67,7 @@ int main(int argc, char** argv) {
for (int i = 0; i < size_in_datum; ++i) {
sum_blob.add_data(0.);
}
LOG(INFO) << "Starting Iteration";
LOG(INFO) << "Starting iteration";
while (cursor->valid()) {
Datum datum;
datum.ParseFromString(cursor->value());
Expand Down Expand Up @@ -114,7 +116,7 @@ int main(int argc, char** argv) {
for (int i = 0; i < dim; ++i) {
mean_values[c] += sum_blob.data(dim * c + i);
}
LOG(INFO) << "mean_value channel [" << c << "]:" << mean_values[c] / dim;
LOG(INFO) << "mean_value channel [" << c << "]: " << mean_values[c] / dim;
}
#else
LOG(FATAL) << "This tool requires OpenCV; compile with USE_OPENCV.";
Expand Down

0 comments on commit c11e782

Please sign in to comment.