ApplyUpdata
。我有两个问题:
参数实际上在ApplyUpdata
中更新吗? backward
仅计算梯度,而对参数没有任何作用?
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_;
}