Search code examples
c++machine-learningdeep-learningcaffeglog

What does "InitGoogleLogging" do?


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.


Solution

  • 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.