MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / Step

Method Step

rtpose_wrapper/src/caffe/solver.cpp:194–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192
193template <typename Dtype>
194void Solver<Dtype>::Step(int iters) {
195 const int start_iter = iter_;
196 const int stop_iter = iter_ + iters;
197 int average_loss = this->param_.average_loss();
198 losses_.clear();
199 smoothed_loss_ = 0;
200
201 while (iter_ < stop_iter) {
202 //if(iter_ == 0) Snapshot();
203
204 // zero-init the params
205 net_->ClearParamDiffs();
206 if (param_.test_interval() && iter_ % param_.test_interval() == 0
207 && (iter_ > 0 || param_.test_initialization())
208 && Caffe::root_solver()) {
209 TestAll();
210 if (requested_early_exit_) {
211 // Break out of the while loop because stop was requested while testing.
212 break;
213 }
214 }
215
216 for (int i = 0; i < callbacks_.size(); ++i) {
217 callbacks_[i]->on_start();
218 }
219 const bool display = param_.display() && iter_ % param_.display() == 0;
220 net_->set_debug_info(display && param_.debug_info());
221 // accumulate the loss and gradient
222 Dtype loss = 0;
223 for (int i = 0; i < param_.iter_size(); ++i) {
224 loss += net_->ForwardBackward();
225 }
226 loss /= param_.iter_size();
227 // average the loss across iterations for smoothed reporting
228 UpdateSmoothedLoss(loss, start_iter, average_loss);
229 if (display) {
230 LOG_IF(INFO, Caffe::root_solver()) << "Iteration " << iter_
231 << ", loss = " << smoothed_loss_;
232 const vector<Blob<Dtype>*>& result = net_->output_blobs();
233 int score_index = 0;
234 for (int j = 0; j < result.size(); ++j) {
235 const Dtype* result_vec = result[j]->cpu_data();
236 const string& output_name =
237 net_->blob_names()[net_->output_blob_indices()[j]];
238 const Dtype loss_weight =
239 net_->blob_loss_weights()[net_->output_blob_indices()[j]];
240 for (int k = 0; k < result[j]->count(); ++k) {
241 ostringstream loss_msg_stream;
242 if (loss_weight) {
243 loss_msg_stream << " (* " << loss_weight
244 << " = " << loss_weight * result_vec[k] << " loss)";
245 }
246 LOG_IF(INFO, Caffe::root_solver()) << " Train net output #"
247 << score_index++ << ": " << output_name << " = "
248 << result_vec[k] << loss_msg_stream.str();
249 }
250 }
251 }

Callers 2

InternalThreadEntryMethod · 0.80
solver_stepFunction · 0.80

Calls 10

GetRequestedActionFunction · 0.85
clearMethod · 0.80
ClearParamDiffsMethod · 0.80
set_debug_infoMethod · 0.80
ForwardBackwardMethod · 0.80
countMethod · 0.80
sizeMethod · 0.45
on_startMethod · 0.45
cpu_dataMethod · 0.45
on_gradients_readyMethod · 0.45

Tested by

no test coverage detected