# Welcome to barrista’s documentation!¶

Barrista will serve your caffe right! It is a Python library that offers a full-featured interface to caffe, similar to keras and Theano.

# Why barrista?¶

barrista gives you full, pythonic control over the entire caffe framework. It is different from the plain caffe Python interface in the way, that it exposes the entire caffe functionality (from net design over training and prediction) in a principled way to Python.

• Design your nets with the full power of caffe within Python. Creating a network is as easy as:

import barrista.design as ds
netspec = ds.NetSpecification([[10, 3, 51, 51], [10]],
# batchsize 10, 3 dim. of 51x51 signal, 10 labels
inputs=['data', 'annotations'])
netspec.layers.append(ds.ConvolutionLayer(Convolution_kernel_size=3,
Convolution_num_output=1))
# The layers are wired together automatically, unless you specify something else:
netspec.layers.append(ds.InnerProductLayer(tops=['net_out'],
InnerProduct_num_output=10))
netspec.layers.append(ds.SoftmaxWithLossLayer(bottoms=['net_out',
'annotations']))
net = netspec.instantiate()

• barrista naturally understands and writes every .prototxt file your caffe version does! Load .prototxt files (also from the model zoo!) and use or modify the networks with barrista:

netspec.to_prototxt(output_filename='net.prototxt')
net.save('net.caffemodel')  # Save the weights.
new_netspec = ds.NetSpecification.from_prototxt(filename='net.prototxt')
new_network = new_netspec.instantiate()

• Use your networks in a principled way from Python. You get transparent support for repetitive tasks like batching or padding, with a clear separation of preprocessing:

import barrista.solver
net.fit(1000,
barrista.solver.SGDSolver(base_lr=0.01),
X={'data': np.ones((21, 3, 51, 51)),  # Automatically batched.
'annotations': np.zeros((21,))})
net.predict({'data': np.zeros((5, 3, 51, 51)), [...]})

• Use callbacks (functions that are called before and after processing a batch) to monitor training and prediction, or to dynamically modify the data used in the batches. barrista comes with a standard set of frequently used callbacks and it is very easy to add your own:

import barrista.monitoring
net.fit(# ... as before
train_callbacks=[
# Write the network weights every 100 iterations to disk.
barrista.monitoring.Checkpointer('/tmp', 100),
# Get a progress bar with ETA.
barrista.monitoring.ProgressIndicator()])

• barrista is always fully consistent with caffe. We internally inspect the protobuf module generated by caffe to infer the interface. Adding your own layers is as easy as:

import barrista.config
barrista.config.LAYER_TYPES['Amazing'] = ['AmazingParameter']

• It runs on every platform caffe runs on, and can be used with Python 2 and 3.

You can use barrista under the MIT License, which means you may use it freely in any projects. The full license can be found in the main folder of the barrista repository.

# Get the source & documentation¶

The source is hosted on github and the documentation/homepage is available on github pages at http://classner.github.io/barrista.