I would like to find the commit that added the following lines of code to solver.cpp for the deep learning library caffe, which is hosted on Github. I am not a contributor or have any special permissions. How do I do that?

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) {
up vote 3 down vote accepted

First, you have to clone the repository to your machine:

git clone https://github.com/BVLC/caffe.git

Simply use git-blame to find out who committed a certain line:

git blame -L 123,123 path/to/file.cpp

Or, for a range of lines, use -L 100,150 or similar. You may want the option -M which detects if lines were moved.

You can also use git-log for the entire commit log:

git log -L 123,123:path/to/file.cpp

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.