Pycaffe library Caffe is one of the renowned deep learning frameworks which was developed by Berkeley AI Research (BAIR). It is an open source framework for deep learning models and its explicit use. Caffe is purely coded on C++ and Cuda library which makes it fast,compatible and easy to use. Caffe library is integrated with python and matlab interfaces for deep learning practinary
|
caffe.set_mode_gpu()
|
|
The main class that the pycaffe interface exposes is the Net. It has two constructors:
|
|
Create a Net (in this case using the Data Layer specified for training)
|
|
net = caffe.Net('/path/prototxt/descriptor/file', caffe.TRAIN)
|
|
Creates a Net and automatically loads the weights as saved in the provided caffemodel file - in this case using the Data Layer specified for testing.
|
|
net = caffe.Net('/path/prototxt/descriptor/file', '/path/caffemodel/weights/file', caffe.TEST)
|
|
nice_edge_detectors = net.params['conv'].data
|
|
higher_level_filter = net.params['fc'].data
|
|
Computing gradients
|
|
net.backward(start='conv1', end='fc')
|
|
softmax_probabilities = net.blobs['prob'].data
|
|
transformer = caffe.io.Transformer({'data': (1, image.shape[2], image.shape[0], image.shape[1])})
|
|
caffe.params.Pooling
|
|
tools.solvers.MonitoringSolver
|
|
import tools.lmdb_io
|
|
pred = net.predict([input])
|
|
caffe.set_mode_cpu()
|
|
data = net.blobs['data'].data
|
|
net.blobs['data'].data[...] = my_image
|
|
fc_activations = net.blobs['fc'].data
|
|
A forward/backward pass with weight update
|
|
solver.step(1)
|
|
Run the solver until the last iteration
|
|
solver.solve()
|
|
Add Data to the net
|
|
net.forward(start='conv', end='fc')
|
|
softmax_probabilities = net.blobs['prob'].data
|
|
Solver needed in order to train a caffe mode
|
|
solver = caffe.SGDSolver('/path/to/solver/prototxt/file')
|
|
The networks are accessible with
|
|
The networks are accessible with
|
|
training_net = solver.net test_net = solver.test_nets[0] # more than one test net is supported
|
|
tools.data_augmentation
|
|
tools.prototxt.train2deploy
|
|
import tools.pre_processing
|
|
input_image = caffe.io.load_image(IMAGE_FILE)
|
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.