Use Caffe in Torch7
C++ Lua CMake
Switch branches/tags
Nothing to show
Clone or download
szagoruyko Merge pull request #4 from wrongu/master
Compatibility with CPU_ONLY version of Caffe
Latest commit 31a67ca Aug 20, 2015
Permalink
Failed to load latest commit information.
CMakeLists.txt
LICENSE added bsd license Jan 12, 2015
README.md added phase to readme Apr 2, 2015
caffe-1.0-0.rockspec rename Dec 20, 2014
caffe.cpp allow loading network without binary Jul 17, 2015
caffe.lua allow loading network without binary Jul 17, 2015
ffi.lua
init.lua
test.lua added test and modernized code Apr 2, 2015

README.md

torch-caffe-binding

A short binding to use Caffe as a module in Torch7. Has the same functionality as MATLAB bindings.

You have to have installed and built Caffe, then do this:

CAFFE_DIR=/*path-to-caffe-root*/ luarocks install caffe

Forward and backward are supported:

require 'caffe'

net = caffe.Net('deploy.prototxt', 'bvlc_alexnet.caffemodel', 'test')
input = torch.FloatTensor(10,3,227,227)
output = net:forward(input)

gradOutput = torch.FloatTensor(10,1000,1,1)
gradInput = net:backward(input, gradOutput)

Use can also use it inside a network as nn.Module, for example:

require 'caffe'

model = nn.Sequential()
model:add(caffe.Net('deploy.prototxt', 'bvlc_alexnet.caffemodel', 'test'))
model:add(nn.Linear(1000,1))

To load Caffe networks in Torch7 without having Caffe installed use this: https://github.com/szagoruyko/loadcaffe