10

I've been modifying an example C++ program from the Caffe deep learning library and I noticed this code on line 234 that doesn't appear to be referenced again.

::google::InitGoogleLogging(argv[0]);

The argument provided is a prototxt file which defines the parameters of the deep learning model I'm calling. The thing that is confusing me is where the results from this line go? I know they end up being used in the program because if I make a mistake in the prototxt file then the program will crash. However I'm struggling to see how the data is passed to the class performing the classification tasks.

Shai
  • 111,146
  • 38
  • 238
  • 371
Jack Simpson
  • 1,681
  • 3
  • 30
  • 54
  • 1
    No, the argument passed to `initGoogleLogging` is the first argument passed to the application on the command line. This is typically the path to the program file being executed (almost always but still not guaranteed). You should probably start with the [documentation for Google Logging library](https://google-glog.googlecode.com/svn/trunk/doc/glog.html). – Captain Obvlious Sep 02 '15 at 01:53
  • 1
    To clarify I meant that the argument I'm passing to initGoogleLogging is the prototxt file which is coming from the command line argument. What I was confused about was how this was actually being using the in Caffe program when I don't see initGoogleLogging referenced again in the code. – Jack Simpson Sep 02 '15 at 02:31
  • Also found it in the Ceres documentation: http://ceres-solver.org/nnls_tutorial.html#hello-world – Dorian Oct 06 '16 at 00:26
  • Oddly enough that function doesn't seem to do anything though, see e.g. in Ceres: https://github.com/ceres-solver/ceres-solver/blob/e51e9b46f6ca88ab8b2266d0e362771db6d98067/internal/ceres/miniglog/glog/logging.h#L149. It even has the comment `// Do nothing; this is ignored.`. – Ela782 Feb 04 '19 at 15:02

1 Answers1

12

First of all, argv[0] is not the first argument you pass to your executable, but rather the executable name. So you are passing to ::google::InitGoogleLogging the executable name and not the prototxt file.
'glog' module (google logging) is using this name to decorate the log entries it outputs.

Second, caffe is using google logging (aka 'glog') as its logging module, and hence this module must be initialized once when running caffe. This is why you have this

::google::InitGoogleLogging(argv[0]);

in your code.

Bill Lynch
  • 80,138
  • 16
  • 128
  • 173
Shai
  • 111,146
  • 38
  • 238
  • 371