我想找到将以下代码行添加到solver.cpp的提交,用于托管在Github 上的深度学习库caffe。我不是贡献者或有任何特殊权限。我怎么做?
template <typename Dtype>
void SGDSolver<Dtype>::ClipGradients() {
const Dtype clip_gradients = this->param_.clip_gradients();
if (clip_gradients < 0) { return; }
const vector<shared_ptr<Blob<Dtype> > >& net_params = this->net_->params();
Dtype sumsq_diff = 0;
for (int i = 0; i < net_params.size(); ++i) {
if (this->net_->param_owners()[i] < 0) {
sumsq_diff += net_params[i]->sumsq_diff();
}
}
const Dtype l2norm_diff = std::sqrt(sumsq_diff);
if (l2norm_diff > clip_gradients) {
Dtype scale_factor = clip_gradients / l2norm_diff;
LOG(INFO) << "Gradient clipping: scaling down gradients (L2 norm "
<< l2norm_diff << " > " << clip_gradients << ") "
<< "by scale factor " << scale_factor;
for (int i = 0; i < net_params.size(); ++i) {
if (this->net_->param_owners()[i] < 0) {
net_params[i]->scale_diff(scale_factor);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
首先,您必须将存储库克隆到您的机器上:
git clone https://github.com/BVLC/caffe.git
Run Code Online (Sandbox Code Playgroud)
简单地用于git-blame找出谁提交了某行:
git blame -L 123,123 path/to/file.cpp
Run Code Online (Sandbox Code Playgroud)
或者,对于一系列行,使用-L 100,150或类似。您可能需要-M检测线是否移动的选项。
您还可以git-log用于整个提交日志:
git log -L 123,123:path/to/file.cpp
Run Code Online (Sandbox Code Playgroud)
小智 5
具体回应这个问题的标题,而不是描述(因为谷歌搜索与问题标题类似的搜索短语把我带到这里),我建议如下:
将存储库克隆到您的计算机:
git clone https://github.com/BVLC/caffe.git
Run Code Online (Sandbox Code Playgroud)
然后在 git 日志中搜索存在搜索词的所有提交:
git log -S searchTerm
Run Code Online (Sandbox Code Playgroud)
最后,尾部输出以便仅查看最旧的提交,因为这必须是首次添加该特定行的提交:
git log -S searchTerm | tail -4
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4862 次 |
| 最近记录: |