File Exchange

image thumbnail

Deep Learning Toolbox Importer for Caffe Models

Software support package for importing pretrained Caffe Models


Updated 12 May 2021

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 (28)

snow yang

您好,我正在使用Matlab R2019b,尝试多次下载失败,您可以将Alexnet安装zip文件的副本发送给我1819877394@qq.com吗?非常感谢您


how to use neural networks to identify images

Jack freed

Song Decn

I got two kinds of following errors during importing a caffe model:

Error parsing text-format caffe.NetParameter: 27:18: Message type
"caffe.LayerParameter" has no field named "permute_param".

Error parsing text-format caffe.NetParameter: 7:21: Message type
"caffe.LayerParameter" has no field named "pyramid_data_param".

Does anyone has an idea?

Rita Li

i can not install it

Shounak Mitra


This support package is compatible with 17a and onwards.

milad eskandari

what the reason of this eror ? The support package is not compatible with your version of MATLAB or operating system

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.

ankit khivasara

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

Susmita Dey Manasi

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

Hiroyuki Kobayashi

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.


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?

Cheng-Chieh Wei

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

Huzaifa kapasi


Philippe Marion

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?

Philippe Marion

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

=> :-( ???

Ziba Gandomkar

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


is it not compatible with win10?

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!