Skip to content

Commit

Permalink
fixed unnecessary conversions in test_solver, and rearraged common.hp…
Browse files Browse the repository at this point in the history
…p a bit
  • Loading branch information
qipeng committed Aug 1, 2014
1 parent d78a8de commit 21d1d91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
5 changes: 2 additions & 3 deletions include/caffe/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
#include <boost/shared_ptr.hpp>
#include <glog/logging.h>

#include <cmath>
#include <map>
#include <set>
#include <string>

#include <cmath>

#include "caffe/util/device_alternate.hpp"

// Disable the copy and assignment operator for a class.
Expand Down Expand Up @@ -73,6 +72,7 @@ using boost::shared_ptr;
// Common functions and classes from std that caffe often uses.
using std::fstream;
using std::ios;
using std::isnan;
using std::iterator;
using std::make_pair;
using std::map;
Expand All @@ -81,7 +81,6 @@ using std::pair;
using std::set;
using std::string;
using std::vector;
using std::isnan;

// A global initialization function that you should call in your main function.
// Currently it initializes google flags and google logging.
Expand Down
18 changes: 7 additions & 11 deletions src/caffe/test/test_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,14 @@ TYPED_TEST(SolverTest, TestInitTrainTestNets) {
" } "
"} ";
this->InitSolverFromProtoString(proto);
ASSERT_TRUE(static_cast<bool>(this->solver_->net()));
EXPECT_TRUE(static_cast<bool>(this->solver_->net()->has_layer("loss")));
EXPECT_FALSE(static_cast<bool>(this->solver_->net()->has_layer("accuracy")));
ASSERT_TRUE(this->solver_->net() != NULL);
EXPECT_TRUE(this->solver_->net()->has_layer("loss"));
EXPECT_FALSE(this->solver_->net()->has_layer("accuracy"));
ASSERT_EQ(2, this->solver_->test_nets().size());
EXPECT_TRUE(static_cast<bool>(
this->solver_->test_nets()[0]->has_layer("loss")));
EXPECT_TRUE(static_cast<bool>(
this->solver_->test_nets()[0]->has_layer("accuracy")));
EXPECT_FALSE(static_cast<bool>(
this->solver_->test_nets()[1]->has_layer("loss")));
EXPECT_TRUE(static_cast<bool>(
this->solver_->test_nets()[1]->has_layer("accuracy")));
EXPECT_TRUE(this->solver_->test_nets()[0]->has_layer("loss"));
EXPECT_TRUE(this->solver_->test_nets()[0]->has_layer("accuracy"));
EXPECT_FALSE(this->solver_->test_nets()[1]->has_layer("loss"));
EXPECT_TRUE(this->solver_->test_nets()[1]->has_layer("accuracy"));
}

} // namespace caffe

0 comments on commit 21d1d91

Please sign in to comment.