void StochasticGD<ParameterType, SampleType, LabelType, SparseGradientType, DenseGradientType>::Train() { learnrateiter_ = this->LearningRate(); itercount_ = 0; timeutil timer; for (epochcount_ = 0; epochcount_ < this->MaxIter(); ++epochcount_) { LOG(INFO) << "epoch " << epochcount_ << " start"; this->trainiter_->ResetBatch(); timer.tic(); TrainOneEpoch(); double secs = timer.toc(); LOG(INFO) << "batch costs " << secs; LOG(INFO) << "evaluate on train set"; this->EvaluateOnSet(this->trainiter_->GetAllData(), this->trainiter_->GetAllLabel()); if (this->testiter_->IsValid()) { LOG(INFO) << "evaluate on test set"; this->EvaluateOnSet(this->testiter_->GetAllData(), this->testiter_->GetAllLabel()); } } this->ResultStats(this->model_.GetParameters()); }
/** * Function that get two vectors, one for the entries and another to the outs, and train one epoch: */ int Train( PtNet Net, int size, float *entry, int size2, float *out, float l_rate ) { int Ret; /* Inserting the entries: */ Ret = SetEntry( Net, size, entry); /* Getting the wrong out values: */ ActivAll(Net); /* Training one epoch: */ Ret = TrainOneEpoch( Net, out, size2 ); /* Updating the weights: */ UpdateWeights( Net, l_rate ); return Ret; }