From 99571c471d493c650c53be1416bb26d5b984f178 Mon Sep 17 00:00:00 2001 From: "T.E.A de Souza" Date: Sun, 29 Nov 2015 14:24:09 +0800 Subject: Correct type of device_id; disambiguate shared_ptr --- tools/extract_features.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'tools') diff --git a/tools/extract_features.cpp b/tools/extract_features.cpp index 1ef13266..d6562f98 100644 --- a/tools/extract_features.cpp +++ b/tools/extract_features.cpp @@ -16,7 +16,6 @@ using caffe::Blob; using caffe::Caffe; using caffe::Datum; using caffe::Net; -using boost::shared_ptr; using std::string; namespace db = caffe::db; @@ -51,7 +50,7 @@ int feature_extraction_pipeline(int argc, char** argv) { arg_pos = num_required_args; if (argc > arg_pos && strcmp(argv[arg_pos], "GPU") == 0) { LOG(ERROR)<< "Using GPU"; - uint device_id = 0; + int device_id = 0; if (argc > arg_pos + 1) { device_id = atoi(argv[arg_pos + 1]); CHECK_GE(device_id, 0); @@ -95,7 +94,7 @@ int feature_extraction_pipeline(int argc, char** argv) { } */ std::string feature_extraction_proto(argv[++arg_pos]); - shared_ptr > feature_extraction_net( + boost::shared_ptr > feature_extraction_net( new Net(feature_extraction_proto, caffe::TEST)); feature_extraction_net->CopyTrainedLayersFrom(pretrained_binary_proto); @@ -119,15 +118,15 @@ int feature_extraction_pipeline(int argc, char** argv) { int num_mini_batches = atoi(argv[++arg_pos]); - std::vector > feature_dbs; - std::vector > txns; + std::vector > feature_dbs; + std::vector > txns; const char* db_type = argv[++arg_pos]; for (size_t i = 0; i < num_features; ++i) { LOG(INFO)<< "Opening dataset " << dataset_names[i]; - shared_ptr db(db::GetDB(db_type)); + boost::shared_ptr db(db::GetDB(db_type)); db->Open(dataset_names.at(i), db::NEW); feature_dbs.push_back(db); - shared_ptr txn(db->NewTransaction()); + boost::shared_ptr txn(db->NewTransaction()); txns.push_back(txn); } @@ -139,8 +138,8 @@ int feature_extraction_pipeline(int argc, char** argv) { for (int batch_index = 0; batch_index < num_mini_batches; ++batch_index) { feature_extraction_net->Forward(input_vec); for (int i = 0; i < num_features; ++i) { - const shared_ptr > feature_blob = feature_extraction_net - ->blob_by_name(blob_names[i]); + const boost::shared_ptr > feature_blob = + feature_extraction_net->blob_by_name(blob_names[i]); int batch_size = feature_blob->num(); int dim_features = feature_blob->count() / batch_size; const Dtype* feature_blob_data; -- cgit v1.2.3