Home

Awesome

pyNetBuilder

pyNetBuilder is a modular pytonic interface with builtin modules for generating popular caffe networks.

Why pynetbuilder?

A neural network is a Directed acyclic graph (DAG) of layers. The caffe layers and the network is represented using prototxt format. As we go deeper, and add more layers or build more complex DAG's using basic layers, writing the prototxt files becomes tedious. This tool aims to provide a pytonic interface to generate prototxt files.

Dependencies

  1. Caffe (version should include the layer definitions you need for your network)
  2. Google protobuf

Design idea

pyNetBuilder builds on top of caffe's NetSpec class to stich together a network. NetSpec "provides a way to write nets directly in Python, using a natural, functional style." Here is a basic example of writing nets in caffe. pyNetBuilder is to provide generic wrappers to attach blocks of layers to NetSpec in form of Legos.

Lego

A lego is a basic neural network building block. It has:

Lego Types:
from lego.base import BaseLegoFunction
conv_params = dict(name='conv1', num_output=64, kernel_size=7,
  use_global_stats='True', pad=3, stride=2)
conv = BaseLegoFunction('Convolution',params).attach(netspec, [netspec.data])
from lego.hybrid import ShortcutLego
params = dict(name='resnet_block', num_output=256,
                          shortcut='identity', main_branch='bottleneck',
                          stride=1, use_global_stats=false,)
block = ShortcutLego(params).attach(netspec, [last_layer])

To generate a network, you can pass a network specification through a series of legos and the modules will get attached to the Netspec object.

Apps

The apps folder is a collection of python scripts which uses the pynetbuilder modules to create standard caffe network prototxt files from popluar papers. Currently apps for following networks are provided (other contributions are welcome):

Contributing to pyNetBuilder

Contributions to pynetbuilder are welcome.

License

Code licensed under the [BSD 2 clause license] (https://github.com/BVLC/caffe/blob/master/LICENSE). See LICENSE file for terms.

Contact

pynetbuilder was written by Jay Mahadeokar from the Yahoo Vision and ML team. Special thanks to Jack Culpepper, Huy Nguyen, Pierre Garrigues, Sachin Farfade, Clayton Mellina and other members of the team for inputs and review.