File Exchange

image thumbnail

Deep Learning Toolbox Importer for Caffe Models

Software support package for importing pretrained Caffe Models


Updated 12 Dec 2018

This software support package provides functions for importing pretrained models as well as layers of Convolutional Neural Networks (CNNs) from Caffe ( Pretrained models are imported as a SeriesNetwork or a Directed Acyclic Graph (DAG) network object.

Opening the caffeimporter.mlpkginstall file from your operating system or from within MATLAB will initiate the installation process for the release you have.
This mlpkginstall file is functional for R2017a and beyond.

Usage Example (importCaffeNetwork):
% Specify files to import
protofile = 'digitsnet.prototxt';
datafile = 'digits_iter_10000.caffemodel';
% Import network
net = importCaffeNetwork(protofile,datafile)
Usage Example (importCaffeLayers):
% Specify file to import
protofile = 'digitsnet.prototxt';
% Import network layers
layers = importCaffeLayers('digitsnet.prototxt')

For more information on importing Caffe networks, please visit our documentation at

For more information on importing layers from Caffe, please visit our documentation at

To get a list of all the pretrained models supported by MATLAB, please visit

Comments and Ratings (21)

Sorry, but with the latest version I'm still unable to import a Resnet50 model. This is the error I get:

Error using nnet.internal.cnn.caffe.CaffeModelReader/importSeriesNetwork (line 310)
The network 'ResNet-50' is not determined to be a Series Network. Only series networks can be imported.

Error in importCaffeNetwork (line 84)
network = importSeriesNetwork(readerObj);

Ting Su

DAG networks can be imported using the importer released after Sep/12/2018.

Ting Su

Hi Ankit,
The digitsnet.prototxt file is shipped with this importer.

from where to download digitsnet.prototxt file


The network 'GoogleNet' is not determined to be a Series Network. Only series networks can be
imported. Can it enhance its versatility?

Baris Ersoy

Hi I was trying to import SqueezeNet_v_1.0 from caffe. However, I get the following error message:
"The network '' is not determined to be a Series Network. Only series networks can be imported"
Is there any solution to this? It would be really helpful if we could export networks like SqueezeNet, GoogleNet (which contain concat layer) from caffe to matlab.


hua ye

hua ye (view profile)

Same with adhusch. I would also appreciate if 'Deconbolution' layer is supported..

Also support for PReLU layers would be sweet :)

Carl Hart

Echoing adhusch's comment: support for 'Deconvolution' layers would be a very practical improvement.


adhusch (view profile)

Would be great if you could support the import of "Deconvolution" (i.e. transposed convolution) layers, enabling the use of U-Nets.

Thanks for the nice tool! I got an error though while importing a net:

The pooling layer 'pool2' is not compatible with MATLAB. Caffe computes the output size as [13 13
256] but MATLAB computes it as [12 12 256].

Is there any workaround for this?

Hi, I just wonder is there's any way to transfer "tile" layer of CAFFE to MATLAB.


Ok, I understood...
the step 3 (previous comment) ./ -matlabroot $MROOT/R2017a
install effectively importCaffexxxx in the matlbrootdirectory BUT also a lot of stuff in /root/Documents/MATLAB/...
=> Consequentce: only root is able to use the add-ons !!???
Is there an other solution to install an add-on for every user on a platform?

install on HPC using command line would be great...:
1) first: (no command line) : choose "download" (whearas install in a graphical session)
2) transfer the package to your HPC main node (default download directory : ~/MathWorks/SupportedPackages
3) ./ -matlabroot $MROOT/R2017a
4) test (the previous example on this page) ... produce the following error:
net = importCaffeNetwork(protofile,datafile)
Error using importCaffeNetwork (line 77)
importCaffeNetwork requires the Neural Network Toolbox Importer for Caffe Models support package. To install this
support package, use the <a href="matlab:
matlab.addons.supportpackage.internal.explorer.showSupportPackages('CAFFEIMPORTER', 'tripwire')">Add-On

=> :-( ???

I was wondering if there is a way to install this package on the HPC (using command line)? Thanks a heap in advance!


sconly (view profile)

is it not compatible with win10?

MATLAB Release Compatibility
Created with R2017a
Compatible with R2017a to R2019a
Platform Compatibility
Windows macOS Linux

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor