# (specify NetParameters directly in the solver, specify multiple test nets)
# if desired.
#
-# test_iter specifies how many forward passes the test should carry out.
-# In the case of MNIST, we have test batch size 100 and 100 test iterations,
-# covering the full 10,000 testing images.
-test_iter: 100
# Carry out testing every 500 training iterations.
test_interval: 500
# The base learning rate, momentum and the weight decay of the network.
random_seed: 1701
# solver mode: CPU or GPU
solver_mode: GPU
+
# The training protocol buffer definition
train_net_param {
name: "LeNet"
bottom: "label"
}
}
+
+# test_iter specifies how many forward passes the test should carry out.
+# In the case of MNIST, we have test batch size 100 and 100 test iterations,
+# covering the full 10,000 testing images.
+test_iter: 100
# The testing protocol buffer definition
test_net_param {
name: "LeNet-test"
top: "accuracy"
}
}
+
+# The train set has 60K images, so we run 600 test iters (600 * 100 = 60K).
+test_iter: 600
# The protocol buffer definition to test on the train set
test_net_param {
name: "LeNet-test-on-train"
const int num_test_net_files = param_.test_net_size();
const int num_test_nets = num_test_net_params + num_test_net_files;
if (num_test_nets) {
- CHECK_EQ(param_.test_iter().size(), num_test_nets) << "you need to specify test_iter for each test network.";
+ CHECK_EQ(param_.test_iter_size(), num_test_nets)
+ << "test_iter must be specified for each test network.";
CHECK_GT(param_.test_interval(), 0);
}
test_nets_.resize(num_test_nets);
template <typename Dtype>
void Solver<Dtype>::Test(const int test_net_id) {
- LOG(INFO) << "Iteration " << iter_ << ", Testing net (#" << test_net_id << ")";
+ LOG(INFO) << "Iteration " << iter_
+ << ", Testing net (#" << test_net_id << ")";
// We need to set phase to test before running.
Caffe::set_phase(Caffe::TEST);
CHECK_NOTNULL(test_nets_[test_net_id].get())->
vector<Dtype> test_score;
vector<Blob<Dtype>*> bottom_vec;
Dtype loss = 0;
- for (int i = 0; i < param_.test_iter().Get(test_net_id); ++i) {
+ for (int i = 0; i < param_.test_iter(test_net_id); ++i) {
Dtype iter_loss;
const vector<Blob<Dtype>*>& result =
test_nets_[test_net_id]->Forward(bottom_vec, &iter_loss);
}
}
if (param_.test_compute_loss()) {
- loss /= param_.test_iter().Get(test_net_id);
+ loss /= param_.test_iter(test_net_id);
LOG(INFO) << "Test loss: " << loss;
}
for (int i = 0; i < test_score.size(); ++i) {
LOG(INFO) << "Test score #" << i << ": "
- << test_score[i] / param_.test_iter().Get(test_net_id);
+ << test_score[i] / param_.test_iter(test_net_id);
}
Caffe::set_phase(Caffe::TRAIN);
}