reapply namespace change
authorYangqing Jia <jiayq@google.com>
Fri, 18 Jul 2014 22:18:14 +0000 (15:18 -0700)
committerYangqing Jia <jiayq@google.com>
Fri, 18 Jul 2014 22:18:14 +0000 (15:18 -0700)
42 files changed:
include/caffe/common.hpp
include/caffe/layer.hpp
include/caffe/net.hpp
include/caffe/test/test_gradient_check_util.hpp
include/caffe/util/insert_splits.hpp
include/caffe/util/io.hpp
include/caffe/util/upgrade_proto.hpp
src/caffe/layer_factory.cpp
src/caffe/layers/accuracy_layer.cpp
src/caffe/layers/bnll_layer.cpp
src/caffe/layers/bnll_layer.cu
src/caffe/layers/dropout_layer.cu
src/caffe/layers/hdf5_output_layer.cpp
src/caffe/layers/hdf5_output_layer.cu
src/caffe/layers/hinge_loss_layer.cpp
src/caffe/layers/image_data_layer.cpp
src/caffe/layers/image_data_layer.cu
src/caffe/layers/infogain_loss_layer.cpp
src/caffe/layers/loss_layer.cpp
src/caffe/layers/multinomial_logistic_loss_layer.cpp
src/caffe/layers/pooling_layer.cpp
src/caffe/layers/pooling_layer.cu
src/caffe/layers/power_layer.cpp
src/caffe/layers/power_layer.cu
src/caffe/layers/relu_layer.cpp
src/caffe/layers/relu_layer.cu
src/caffe/layers/sigmoid_cross_entropy_loss_layer.cpp
src/caffe/layers/sigmoid_cross_entropy_loss_layer.cu
src/caffe/layers/sigmoid_layer.cu
src/caffe/layers/softmax_layer.cpp
src/caffe/layers/softmax_layer.cu
src/caffe/layers/softmax_loss_layer.cpp
src/caffe/layers/softmax_loss_layer.cu
src/caffe/layers/threshold_layer.cu
src/caffe/layers/window_data_layer.cpp
src/caffe/layers/window_data_layer.cu
src/caffe/net.cpp
src/caffe/solver.cpp
src/caffe/test/test_power_layer.cpp
src/caffe/util/insert_splits.cpp
src/caffe/util/io.cpp
src/caffe/util/upgrade_proto.cpp

index cf4fd45..2c79f2b 100644 (file)
@@ -68,6 +68,17 @@ namespace caffe {
 // because cuda does not work (at least now) well with C++11 features.
 using boost::shared_ptr;
 
+// Common functions and classes from std that caffe often uses.
+using std::fstream;
+using std::ios;
+using std::iterator;
+using std::make_pair;
+using std::map;
+using std::ostringstream;
+using std::pair;
+using std::set;
+using std::string;
+using std::vector;
 
 // A singleton class to hold common caffe stuff, such as the handler that
 // caffe is going to use for cublas, curand, etc.
index 6d2374f..aac8244 100644 (file)
@@ -13,9 +13,6 @@
 
 namespace caffe {
 
-using std::string;
-using std::vector;
-
 template <typename Dtype>
 class Layer {
  public:
index ce82e28..8a2df2b 100644 (file)
 
 namespace caffe {
 
-using std::map;
-using std::pair;
-using std::set;
-using std::string;
-using std::vector;
-
 template <typename Dtype>
 class Net {
  public:
index 2d551f8..034aecc 100644 (file)
@@ -13,8 +13,6 @@
 #include "caffe/layer.hpp"
 #include "caffe/net.hpp"
 
-using std::max;
-
 namespace caffe {
 
 // The gradient checker adds a L2 normalization loss function on top of the
@@ -160,8 +158,8 @@ void GradientChecker<Dtype>::CheckGradientSingle(Layer<Dtype>* layer,
           || fabs(feature) > kink_ + kink_range_) {
         // We check relative accuracy, but for too small values, we threshold
         // the scale factor by 1.
-        Dtype scale = max(
-            max(fabs(computed_gradient), fabs(estimated_gradient)), 1.);
+        Dtype scale = std::max(
+            std::max(fabs(computed_gradient), fabs(estimated_gradient)), 1.);
         EXPECT_NEAR(computed_gradient, estimated_gradient, threshold_ * scale)
           << "debug: (top_id, top_data_id, blob_id, feat_id)="
           << top_id << "," << top_data_id << "," << blob_id << "," << feat_id;
index 45c3a05..4da1ea8 100644 (file)
@@ -9,9 +9,6 @@
 
 namespace caffe {
 
-using std::pair;
-using std::string;
-
 // Copy NetParameters with SplitLayers added to replace any shared bottom
 // blobs with unique bottom blobs provided by the SplitLayer.
 void InsertSplits(const NetParameter& param, NetParameter* param_split);
index accb094..631dbe7 100644 (file)
@@ -16,7 +16,6 @@
 
 namespace caffe {
 
-using std::string;
 using ::google::protobuf::Message;
 
 bool ReadProtoFromTextFile(const char* filename, Message* proto);
index 0772f80..39e4f4c 100644 (file)
@@ -10,8 +10,6 @@
 
 namespace caffe {
 
-using std::string;
-
 // Return true iff any layer contains parameters specified using
 // deprecated V0LayerParameter.
 bool NetNeedsUpgrade(const NetParameter& net_param);
index 173c870..e6cbe18 100644 (file)
@@ -11,8 +11,6 @@
 
 namespace caffe {
 
-using std::string;
-
 // A function to get a specific layer from the specification given in
 // LayerParameter. Ideally this would be replaced by a factory pattern,
 // but we will leave it this way for now.
index ddfe38a..95439b9 100644 (file)
@@ -13,8 +13,6 @@
 
 namespace caffe {
 
-using std::max;
-
 template <typename Dtype>
 void AccuracyLayer<Dtype>::SetUp(
   const vector<Blob<Dtype>*>& bottom, vector<Blob<Dtype>*>* top) {
index 992c7e0..9b7a064 100644 (file)
@@ -8,8 +8,6 @@
 
 namespace caffe {
 
-using std::min;
-
 const float kBNLL_THRESHOLD = 50.;
 
 template <typename Dtype>
@@ -37,7 +35,7 @@ void BNLLLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,
     const int count = (*bottom)[0]->count();
     Dtype expval;
     for (int i = 0; i < count; ++i) {
-      expval = exp(min(bottom_data[i], Dtype(kBNLL_THRESHOLD)));
+      expval = exp(std::min(bottom_data[i], Dtype(kBNLL_THRESHOLD)));
       bottom_diff[i] = top_diff[i] * expval / (expval + 1.);
     }
   }
index 8fbe7f7..bc6a201 100644 (file)
@@ -8,8 +8,6 @@
 
 namespace caffe {
 
-using std::max;
-
 const float kBNLL_THRESHOLD = 50.;
 
 template <typename Dtype>
index c9f3ecd..2316c9e 100644 (file)
@@ -10,8 +10,6 @@
 #include "caffe/vision_layers.hpp"
 #include "caffe/util/math_functions.hpp"
 
-using std::max;
-
 namespace caffe {
 
 
index ffa240f..accc9f9 100644 (file)
@@ -12,7 +12,6 @@
 #include "caffe/vision_layers.hpp"
 
 namespace caffe {
-using std::vector;
 
 template <typename Dtype>
 HDF5OutputLayer<Dtype>::HDF5OutputLayer(const LayerParameter& param)
index 744b8fe..5c79055 100644 (file)
@@ -12,7 +12,6 @@
 #include "caffe/vision_layers.hpp"
 
 namespace caffe {
-using std::vector;
 
 template <typename Dtype>
 Dtype HDF5OutputLayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
index 8097761..91fe153 100644 (file)
@@ -10,8 +10,6 @@
 #include "caffe/util/math_functions.hpp"
 #include "caffe/util/io.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
@@ -30,7 +28,8 @@ Dtype HingeLossLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
   }
   for (int i = 0; i < num; ++i) {
     for (int j = 0; j < dim; ++j) {
-      bottom_diff[i * dim + j] = max(Dtype(0), 1 + bottom_diff[i * dim + j]);
+      bottom_diff[i * dim + j] = std::max(
+        Dtype(0), 1 + bottom_diff[i * dim + j]);
     }
   }
   switch (this->layer_param_.hinge_loss_param().norm()) {
index 408452f..e7779ae 100644 (file)
@@ -18,9 +18,6 @@
 
 namespace caffe {
 
-using std::iterator;
-using std::pair;
-
 template <typename Dtype>
 void* ImageDataLayerPrefetch(void* layer_pointer) {
   CHECK(layer_pointer);
index cf74853..0fa5842 100644 (file)
@@ -17,8 +17,6 @@
 
 namespace caffe {
 
-using std::pair;
-
 template <typename Dtype>
 Dtype ImageDataLayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
       vector<Blob<Dtype>*>* top) {
index a72874e..204f6c3 100644 (file)
@@ -10,8 +10,6 @@
 #include "caffe/util/math_functions.hpp"
 #include "caffe/util/io.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
@@ -44,7 +42,7 @@ Dtype InfogainLossLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
   for (int i = 0; i < num; ++i) {
     int label = static_cast<int>(bottom_label[i]);
     for (int j = 0; j < dim; ++j) {
-      Dtype prob = max(bottom_data[i * dim + j], Dtype(kLOG_THRESHOLD));
+      Dtype prob = std::max(bottom_data[i * dim + j], Dtype(kLOG_THRESHOLD));
       loss -= infogain_mat[label * dim + j] * log(prob);
     }
   }
@@ -73,7 +71,7 @@ void InfogainLossLayer<Dtype>::Backward_cpu(const vector<Blob<Dtype>*>& top,
     for (int i = 0; i < num; ++i) {
       int label = static_cast<int>(bottom_label[i]);
       for (int j = 0; j < dim; ++j) {
-        Dtype prob = max(bottom_data[i * dim + j], Dtype(kLOG_THRESHOLD));
+        Dtype prob = std::max(bottom_data[i * dim + j], Dtype(kLOG_THRESHOLD));
         bottom_diff[i * dim + j] = - infogain_mat[label * dim + j] / prob / num;
       }
     }
index ac8ad21..92eb06f 100644 (file)
@@ -10,8 +10,6 @@
 #include "caffe/util/math_functions.hpp"
 #include "caffe/util/io.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
index 8687784..beea747 100644 (file)
@@ -10,8 +10,6 @@
 #include "caffe/util/math_functions.hpp"
 #include "caffe/util/io.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
@@ -32,7 +30,8 @@ Dtype MultinomialLogisticLossLayer<Dtype>::Forward_cpu(
   Dtype loss = 0;
   for (int i = 0; i < num; ++i) {
     int label = static_cast<int>(bottom_label[i]);
-    Dtype prob = max(bottom_data[i * dim + label], Dtype(kLOG_THRESHOLD));
+    Dtype prob = std::max(
+        bottom_data[i * dim + label], Dtype(kLOG_THRESHOLD));
     loss -= log(prob);
   }
   if (top->size() == 1) {
@@ -58,7 +57,8 @@ void MultinomialLogisticLossLayer<Dtype>::Backward_cpu(
     caffe_set((*bottom)[0]->count(), Dtype(0), bottom_diff);
     for (int i = 0; i < num; ++i) {
       int label = static_cast<int>(bottom_label[i]);
-      Dtype prob = max(bottom_data[i * dim + label], Dtype(kLOG_THRESHOLD));
+      Dtype prob = std::max(
+          bottom_data[i * dim + label], Dtype(kLOG_THRESHOLD));
       bottom_diff[i * dim + label] = -1. / prob / num;
     }
   }
index d6fef07..37da4d1 100644 (file)
 #include "caffe/syncedmem.hpp"
 #include "caffe/util/math_functions.hpp"
 
-using std::max;
-using std::min;
-
 namespace caffe {
 
+using std::min;
+using std::max;
+
 template <typename Dtype>
 void PoolingLayer<Dtype>::SetUp(const vector<Blob<Dtype>*>& bottom,
       vector<Blob<Dtype>*>* top) {
index a44b177..4aa9492 100644 (file)
@@ -8,9 +8,6 @@
 #include "caffe/vision_layers.hpp"
 #include "caffe/util/math_functions.hpp"
 
-using std::max;
-using std::min;
-
 namespace caffe {
 
 template <typename Dtype>
index 4607457..55ace20 100644 (file)
@@ -7,8 +7,6 @@
 #include "caffe/vision_layers.hpp"
 #include "caffe/util/math_functions.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
index e7f9831..0aa0027 100644 (file)
@@ -7,8 +7,6 @@
 #include "caffe/vision_layers.hpp"
 #include "caffe/util/math_functions.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
index 6d60174..1e11955 100644 (file)
@@ -6,8 +6,6 @@
 #include "caffe/layer.hpp"
 #include "caffe/vision_layers.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
@@ -17,7 +15,7 @@ Dtype ReLULayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
   Dtype* top_data = (*top)[0]->mutable_cpu_data();
   const int count = bottom[0]->count();
   for (int i = 0; i < count; ++i) {
-    top_data[i] = max(bottom_data[i], Dtype(0));
+    top_data[i] = std::max(bottom_data[i], Dtype(0));
   }
   return Dtype(0);
 }
index 2ad6891..e8b0fbe 100644 (file)
@@ -6,8 +6,6 @@
 #include "caffe/layer.hpp"
 #include "caffe/vision_layers.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
index 074fa6c..31522dd 100644 (file)
@@ -8,8 +8,6 @@
 #include "caffe/vision_layers.hpp"
 #include "caffe/util/math_functions.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
index 0c858cd..1d1f8cd 100644 (file)
@@ -8,8 +8,6 @@
 #include "caffe/vision_layers.hpp"
 #include "caffe/util/math_functions.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
index d55968e..28cc7f1 100644 (file)
@@ -7,8 +7,6 @@
 #include "caffe/layer.hpp"
 #include "caffe/vision_layers.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
index 665cfae..0de1403 100644 (file)
@@ -7,8 +7,6 @@
 #include "caffe/vision_layers.hpp"
 #include "caffe/util/math_functions.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
@@ -40,7 +38,7 @@ Dtype SoftmaxLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
   for (int i = 0; i < num; ++i) {
     scale_data[i] = bottom_data[i*dim];
     for (int j = 0; j < dim; ++j) {
-      scale_data[i] = max(scale_data[i], bottom_data[i * dim + j]);
+      scale_data[i] = std::max(scale_data[i], bottom_data[i * dim + j]);
     }
   }
   // subtraction
index ceeaff5..d471ba5 100644 (file)
@@ -10,8 +10,6 @@
 #include "caffe/vision_layers.hpp"
 #include "caffe/util/math_functions.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
index c87270e..4e957ce 100644 (file)
@@ -8,8 +8,6 @@
 #include "caffe/vision_layers.hpp"
 #include "caffe/util/math_functions.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
@@ -43,8 +41,8 @@ Dtype SoftmaxWithLossLayer<Dtype>::Forward_cpu(
   int dim = prob_.count() / num;
   Dtype loss = 0;
   for (int i = 0; i < num; ++i) {
-    loss += -log(max(prob_data[i * dim + static_cast<int>(label[i])],
-                     Dtype(FLT_MIN)));
+    loss += -log(std::max(prob_data[i * dim + static_cast<int>(label[i])],
+                          Dtype(FLT_MIN)));
   }
   if (top->size() >= 1) {
     (*top)[0]->mutable_cpu_data()[0] = loss / num;
index e46be6b..ae7060d 100644 (file)
@@ -8,8 +8,6 @@
 #include "caffe/vision_layers.hpp"
 #include "caffe/util/math_functions.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
index 03eb3f3..fb973b2 100644 (file)
@@ -6,8 +6,6 @@
 #include "caffe/layer.hpp"
 #include "caffe/vision_layers.hpp"
 
-using std::max;
-
 namespace caffe {
 
 template <typename Dtype>
index c45a152..8c8de34 100644 (file)
@@ -28,9 +28,6 @@
 
 namespace caffe {
 
-using std::map;
-using std::pair;
-
 template <typename Dtype>
 void* WindowDataLayerPrefetch(void* layer_pointer) {
   WindowDataLayer<Dtype>* layer =
index d4efeca..49f67d2 100644 (file)
@@ -18,9 +18,6 @@
 
 namespace caffe {
 
-using std::map;
-using std::pair;
-
 template <typename Dtype>
 Dtype WindowDataLayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
       vector<Blob<Dtype>*>* top) {
index aba4cc2..520ee58 100644 (file)
 #include "caffe/util/math_functions.hpp"
 #include "caffe/util/upgrade_proto.hpp"
 
-using std::make_pair;
-using std::map;
-using std::pair;
-using std::set;
 
 namespace caffe {
 
index edfa9c0..a331497 100644 (file)
@@ -12,9 +12,6 @@
 #include "caffe/util/io.hpp"
 #include "caffe/util/math_functions.hpp"
 
-using std::max;
-using std::min;
-
 namespace caffe {
 
 template <typename Dtype>
index c9992d5..d4e6fc5 100644 (file)
@@ -55,8 +55,8 @@ class PowerLayerTest : public MultiDeviceTest<TypeParam> {
       if (isnan(expected_value)) {
         EXPECT_TRUE(isnan(top_data[i]));
       } else {
-        Dtype precision = max(Dtype(abs(expected_value * 0.0001)),
-                              min_precision);
+        Dtype precision = std::max(
+          Dtype(std::abs(expected_value * Dtype(1e-4))), min_precision);
         EXPECT_NEAR(expected_value, top_data[i], precision);
       }
     }
index b9aeb37..4de5468 100644 (file)
@@ -8,11 +8,6 @@
 #include "caffe/common.hpp"
 #include "caffe/util/insert_splits.hpp"
 
-using std::map;
-using std::ostringstream;
-using std::pair;
-using std::make_pair;
-
 namespace caffe {
 
 void InsertSplits(const NetParameter& param, NetParameter* param_split) {
index ff65bd6..4f20047 100644 (file)
 #include "caffe/util/io.hpp"
 #include "caffe/proto/caffe.pb.h"
 
-using std::fstream;
-using std::ios;
-using std::max;
-using std::string;
+namespace caffe {
+
 using google::protobuf::io::FileInputStream;
 using google::protobuf::io::FileOutputStream;
 using google::protobuf::io::ZeroCopyInputStream;
@@ -31,8 +29,6 @@ using google::protobuf::io::ZeroCopyOutputStream;
 using google::protobuf::io::CodedOutputStream;
 using google::protobuf::Message;
 
-namespace caffe {
-
 bool ReadProtoFromTextFile(const char* filename, Message* proto) {
   int fd = open(filename, O_RDONLY);
   CHECK_NE(fd, -1) << "File not found: " << filename;
index e079b42..a17beed 100644 (file)
@@ -12,9 +12,6 @@
 #include "caffe/util/upgrade_proto.hpp"
 #include "caffe/proto/caffe.pb.h"
 
-using std::map;
-using std::string;
-
 namespace caffe {
 
 bool NetNeedsUpgrade(const NetParameter& net_param) {