From f019d0dfe86f49d1140961f8c7dec22130c83154 Mon Sep 17 00:00:00 2001 From: Kuang Fangjun Date: Thu, 12 Jul 2018 16:36:06 +0800 Subject: [PATCH] fix typos and some minor fixes. --- cmake/Modules/FindMKL.cmake | 2 +- include/caffe/net.hpp | 6 +++--- include/caffe/solver.hpp | 4 ++-- include/caffe/util/signal_handler.h | 2 +- python/caffe/_caffe.cpp | 2 +- src/caffe/layers/pooling_layer.cpp | 2 +- src/caffe/net.cpp | 8 ++++---- src/caffe/proto/caffe.proto | 6 +++--- src/caffe/solver.cpp | 6 +++--- src/caffe/util/signal_handler.cpp | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/cmake/Modules/FindMKL.cmake b/cmake/Modules/FindMKL.cmake index 5ab93b2d6b6..ef0c3bf1c64 100644 --- a/cmake/Modules/FindMKL.cmake +++ b/cmake/Modules/FindMKL.cmake @@ -9,7 +9,7 @@ # This module defines the following variables: # # MKL_FOUND : True mkl is found -# MKL_INCLUDE_DIR : unclude directory +# MKL_INCLUDE_DIR : include directory # MKL_LIBRARIES : the libraries to link against. diff --git a/include/caffe/net.hpp b/include/caffe/net.hpp index d3c9306e9cf..143d5d28883 100644 --- a/include/caffe/net.hpp +++ b/include/caffe/net.hpp @@ -111,9 +111,9 @@ class Net { * another Net. */ void CopyTrainedLayersFrom(const NetParameter& param); - void CopyTrainedLayersFrom(const string trained_filename); - void CopyTrainedLayersFromBinaryProto(const string trained_filename); - void CopyTrainedLayersFromHDF5(const string trained_filename); + void CopyTrainedLayersFrom(const string& trained_filename); + void CopyTrainedLayersFromBinaryProto(const string& trained_filename); + void CopyTrainedLayersFromHDF5(const string& trained_filename); /// @brief Writes the net to a proto. void ToProto(NetParameter* param, bool write_diff = false) const; /// @brief Writes the net to an HDF5 file. diff --git a/include/caffe/solver.hpp b/include/caffe/solver.hpp index 75560f9fd08..7a0d7777f2d 100644 --- a/include/caffe/solver.hpp +++ b/include/caffe/solver.hpp @@ -55,7 +55,7 @@ class Solver { // The main entry of the solver function. In default, iter will be zero. Pass // in a non-zero iter number to resume training for a pre-trained net. virtual void Solve(const char* resume_file = NULL); - inline void Solve(const string resume_file) { Solve(resume_file.c_str()); } + inline void Solve(const string& resume_file) { Solve(resume_file.c_str()); } void Step(int iters); // The Restore method simply dispatches to one of the // RestoreSolverStateFrom___ protected methods. You should implement these @@ -98,7 +98,7 @@ class Solver { virtual void ApplyUpdate() = 0; protected: - string SnapshotFilename(const string extension); + string SnapshotFilename(const string& extension); string SnapshotToBinaryProto(); string SnapshotToHDF5(); // The test routine diff --git a/include/caffe/util/signal_handler.h b/include/caffe/util/signal_handler.h index fb84c65bd2e..5246332581e 100644 --- a/include/caffe/util/signal_handler.h +++ b/include/caffe/util/signal_handler.h @@ -8,7 +8,7 @@ namespace caffe { class SignalHandler { public: - // Contructor. Specify what action to take when a signal is received. + // Constructor. Specify what action to take when a signal is received. SignalHandler(SolverAction::Enum SIGINT_action, SolverAction::Enum SIGHUP_action); ~SignalHandler(); diff --git a/python/caffe/_caffe.cpp b/python/caffe/_caffe.cpp index 9e7f61402c4..82bf21e6e16 100644 --- a/python/caffe/_caffe.cpp +++ b/python/caffe/_caffe.cpp @@ -416,7 +416,7 @@ BOOST_PYTHON_MODULE(_caffe) { .def("reshape", &Net::Reshape) .def("clear_param_diffs", &Net::ClearParamDiffs) // The cast is to select a particular overload. - .def("copy_from", static_cast::*)(const string)>( + .def("copy_from", static_cast::*)(const string&)>( &Net::CopyTrainedLayersFrom)) .def("share_with", &Net::ShareTrainedLayersWith) .add_property("_blob_loss_weights", bp::make_function( diff --git a/src/caffe/layers/pooling_layer.cpp b/src/caffe/layers/pooling_layer.cpp index 90897db0f45..1fa78904ea8 100644 --- a/src/caffe/layers/pooling_layer.cpp +++ b/src/caffe/layers/pooling_layer.cpp @@ -132,7 +132,7 @@ void PoolingLayer::Forward_cpu(const vector*>& bottom, const int top_count = top[0]->count(); // We'll output the mask to top[1] if it's of size >1. const bool use_top_mask = top.size() > 1; - int* mask = NULL; // suppress warnings about uninitalized variables + int* mask = NULL; // suppress warnings about uninitialized variables Dtype* top_mask = NULL; // Different pooling methods. We explicitly do the switch outside the for // loop to save time, although this results in more code. diff --git a/src/caffe/net.cpp b/src/caffe/net.cpp index 353c2f95b9e..94c0220f172 100644 --- a/src/caffe/net.cpp +++ b/src/caffe/net.cpp @@ -164,7 +164,7 @@ void Net::Init(const NetParameter& in_param) { // loss. We can skip backward computation for blobs that don't contribute // to the loss. // Also checks if all bottom blobs don't need backward computation (possible - // because the skip_propagate_down param) and so we can skip bacward + // because the skip_propagate_down param) and so we can skip backward // computation for the entire layer set blobs_under_loss; set blobs_skip_backp; @@ -768,7 +768,7 @@ void Net::CopyTrainedLayersFrom(const NetParameter& param) { } template -void Net::CopyTrainedLayersFrom(const string trained_filename) { +void Net::CopyTrainedLayersFrom(const string& trained_filename) { if (H5Fis_hdf5(trained_filename.c_str())) { CopyTrainedLayersFromHDF5(trained_filename); } else { @@ -778,14 +778,14 @@ void Net::CopyTrainedLayersFrom(const string trained_filename) { template void Net::CopyTrainedLayersFromBinaryProto( - const string trained_filename) { + const string& trained_filename) { NetParameter param; ReadNetParamsFromBinaryFileOrDie(trained_filename, ¶m); CopyTrainedLayersFrom(param); } template -void Net::CopyTrainedLayersFromHDF5(const string trained_filename) { +void Net::CopyTrainedLayersFromHDF5(const string& trained_filename) { hid_t file_hid = H5Fopen(trained_filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT); CHECK_GE(file_hid, 0) << "Couldn't open " << trained_filename; diff --git a/src/caffe/proto/caffe.proto b/src/caffe/proto/caffe.proto index b9bb3f4dffe..2f8dffc0e1b 100644 --- a/src/caffe/proto/caffe.proto +++ b/src/caffe/proto/caffe.proto @@ -187,7 +187,7 @@ message SolverParameter { optional int32 snapshot = 14 [default = 0]; // The snapshot interval // The prefix for the snapshot. - // If not set then is replaced by prototxt file path without extention. + // If not set then is replaced by prototxt file path without extension. // If is set to directory then is augmented by prototxt file name // without extention. optional string snapshot_prefix = 15; @@ -248,8 +248,8 @@ message SolverParameter { // Path to caffemodel file(s) with pretrained weights to initialize finetuning. // Tha same as command line --weights parameter for caffe train command. - // If command line --weights parameter if specified, it has higher priority - // and owerwrites this one(s). + // If command line --weights parameter is specified, it has higher priority + // and overwrites this one(s). // If --snapshot command line parameter is specified, this one(s) are ignored. // If several model files are expected, they can be listed in a one // weights parameter separated by ',' (like in a command string) or diff --git a/src/caffe/solver.cpp b/src/caffe/solver.cpp index bf27beeed41..842312e0b76 100644 --- a/src/caffe/solver.cpp +++ b/src/caffe/solver.cpp @@ -78,7 +78,7 @@ template void Solver::InitTrainNet() { const int num_train_nets = param_.has_net() + param_.has_net_param() + param_.has_train_net() + param_.has_train_net_param(); - const string& field_names = "net, net_param, train_net, train_net_param"; + const string field_names = "net, net_param, train_net, train_net_param"; CHECK_GE(num_train_nets, 1) << "SolverParameter must specify a train net " << "using one of these fields: " << field_names; CHECK_LE(num_train_nets, 1) << "SolverParameter must not contain more than " @@ -447,13 +447,13 @@ void Solver::CheckSnapshotWritePermissions() { } else { LOG(FATAL) << "Cannot write to snapshot prefix '" << param_.snapshot_prefix() << "'. Make sure " - << "that the directory exists and is writeable."; + << "that the directory exists and is writable."; } } } template -string Solver::SnapshotFilename(const string extension) { +string Solver::SnapshotFilename(const string& extension) { return param_.snapshot_prefix() + "_iter_" + caffe::format_int(iter_) + extension; } diff --git a/src/caffe/util/signal_handler.cpp b/src/caffe/util/signal_handler.cpp index 5d764ec524f..9658fb390ea 100644 --- a/src/caffe/util/signal_handler.cpp +++ b/src/caffe/util/signal_handler.cpp @@ -48,7 +48,7 @@ namespace { void UnhookHandler() { if (already_hooked_up) { struct sigaction sa; - // Setup the sighub handler + // Setup the sighup handler sa.sa_handler = SIG_DFL; // Restart the system call, if at all possible sa.sa_flags = SA_RESTART;