caffe

Topics related to caffe:

Getting started with caffe

Caffe is a library written in C++, to facilitate the experimentation with and use of Convolutional Neural Networks (CNN). Caffe has been developed by Berkeley Vision and Learning Center (BVLC).

Caffe is actually an abbreviation referring to "Convolutional Architectures for Fast Feature Extraction". This acronym encapsulates an important scope of the library. Caffe in the form of a library offers a general programming framework/architecture which can be used to perform efficient training and testing of CNNs. "Efficiency" is a major hallmark of caffe, and stands as a major design objective of Caffe.

Caffe is an open-source library released under BSD 2 Clause license.

Caffe is maintained on GitHub

Caffe can be used to :

  • Efficiently train and test multiple CNN architectures, specifically any architecture that can be represented as a directed acyclic graph (DAG).
  • Utilize multiple GPUs (upto 4) for training and testing. It is recommended that all the GPUs should be of the same type. Otherwise, performance is limited by the limits of the slowest GPU in the system. For example, in case of TitanX and GTX 980, the performance will be limited by the latter. Mixing multiple architectures is not supported, e.g. Kepler and Fermi 3.

Caffe has been written following efficient Object Oriented Programming (OOP) principles.

A good starting point to begin an introduction to caffe is to get a bird's eye view of how caffe works through its fundamental objects.

Training a Caffe model with pycaffe

Prepare Data for Training

Basic Caffe Objects - Solver, Net, Layer and Blob

A caffe user sends instructions to perform specific operations to caffe objects. These objects interact with each other based on their design specifications and carry out the operation(s). This is a basic principle OOP paradigm.

While there are many caffe object types (or C++ classes), for a beginning basic understanding we focus upon 4 important caffe objects. Our objective at this stage is to simply observe the interaction between these objects on a highly abstracted level where specific implementation and design details are hazed out, and instead a bird's eye view of operation is focussed upon.

The 4 basic caffe objects are :

  • Solver
  • Net
  • Layer
  • Blob

A very basic introduction and a bird's eye view of their role in the working of caffe is presented in concise points in the examples section.

After reading and getting a basic idea of how these caffe objects interact, each object type can be read about in detail in their dedicated topics.

Batch normalization

Custom Python Layers

- Caffe build with Python layer

Caffe needs to be compiled with WITH_PYTHON_LAYER option:

WITH_PYTHON_LAYER=1 make && make pycaffe

- Where should I save the class file?

You have two options (at least that I know of). Either you can save the custom layer file in the same folder as you are going to run the caffe command (probably where your prototxt files would be). Another way, also my favorite one, is to save all your custom layers in a folder and adding this folder to your PYTHONPATH.

References

  1. Christopher Bourez's blog
  2. Caffe Github
  3. StackOverflow