参数实际上在caffe的“ ApplyUpdata”中更新吗?

时间:2018-11-14 09:25:11

标签: caffe pycaffe

下面显示了caffe中的

ApplyUpdata。我有两个问题:

  1. 参数实际上在ApplyUpdata中更新吗? backward仅计算梯度,而对参数没有任何作用?

  2. this->iter_是什么意思?以GAN训练为例,如果我想训练生成器三次,而鉴别器只训练一次,我应该如何处理this->iter_,因为ApplyUpdate会增加this->iter_三倍用于生成器,但仅用于鉴别器一次。

THX!

void SGDSolver<Dtype>::ApplyUpdate() {
  Dtype rate = GetLearningRate();
  if (this->param_.display() && this->iter_ % this->param_.display() == 0) {
    LOG_IF(INFO, Caffe::root_solver()) << "Iteration " << this->iter_
        << ", lr = " << rate;
  }
  ClipGradients();
  for (int param_id = 0; param_id < this->net_->learnable_params().size();
       ++param_id) {
    Normalize(param_id);
    Regularize(param_id);
    ComputeUpdateValue(param_id, rate);
  }
  this->net_->Update();

  // Increment the internal iter_ counter -- its value should always indicate
  // the number of times the weights have been updated.
  ++this->iter_;
}

0 个答案:

没有答案