optional int32 test_iter = 3 [default = 0];
// The number of iterations between two testing phases.
optional int32 test_interval = 4 [default = 0];
+ optional bool test_compute_loss = 19 [default = false];
optional float base_lr = 5; // The base learning rate
// the number of iterations between displaying info. If display = 0, no info
// will be displayed.
CHECK_NOTNULL(test_net_.get())->CopyTrainedLayersFrom(net_param);
vector<Dtype> test_score;
vector<Blob<Dtype>*> bottom_vec;
+ Dtype loss = 0;
for (int i = 0; i < param_.test_iter(); ++i) {
+ Dtype iter_loss;
const vector<Blob<Dtype>*>& result =
- test_net_->Forward(bottom_vec);
+ test_net_->Forward(bottom_vec, &iter_loss);
+ if (param_.test_compute_loss()) {
+ loss += iter_loss;
+ }
if (i == 0) {
for (int j = 0; j < result.size(); ++j) {
const Dtype* result_vec = result[j]->cpu_data();
}
}
}
+ if (param_.test_compute_loss()) {
+ loss /= param_.test_iter();
+ 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();