- printVar
printVar
在 hogWildWorker 里训练的时候 printVar
再看看 platform::PrintVars 的逻辑:void HogwildWorker::PrintFetchVars() {// call countbatch_num_++;int batch_per_print = fetch_config_.print_period();if (thread_id_ == 0) {if (batch_num_ % batch_per_print == 0) {int fetch_var_num = fetch_config_.fetch_var_names_size();for (int i = 0; i < fetch_var_num; ++i) {platform::PrintVar(thread_scope_, fetch_config_.fetch_var_names(i),fetch_config_.fetch_var_str_format(i));}}}}
void PrintVar(framework::Scope* scope, const std::string& var_name,const std::string& print_info) {framework::Variable* var = scope->FindVar(var_name);if (var == nullptr) {VLOG(1) << "Variable Name " << var_name << " does not exist in your scope";return;}framework::LoDTensor* tensor = var->GetMutable<framework::LoDTensor>();if (tensor == nullptr) {VLOG(1) << "tensor of variable " << var_name<< " does not exist in your scope";return;}std::ostringstream sstream;sstream << print_info << "\t";sstream << var_name << "\t";sstream << *tensor << "\t";std::cout << sstream.str() << std::endl;}
