6
$\begingroup$

Caffe has its own visualization tools, for instance you and draw all the layers in a network easily like so: enter image description here

But I wanted to analyze a network structure myself in mathematica, so I started to write a prototxt importer, then I saw this:

MachineLearning`CaffeImporter`

In[38]:= Names["MachineLearning`BuiltIn`PackagePrivate`*"]

Out[38]= {"MachineLearning`BuiltIn`PackagePrivate`file", \
"MachineLearning`BuiltIn`PackagePrivate`loadPaclet", \
"MachineLearning`BuiltIn`PackagePrivate`name", \
"MachineLearning`BuiltIn`PackagePrivate`name$", \
"MachineLearning`BuiltIn`PackagePrivate`p", \
"MachineLearning`BuiltIn`PackagePrivate`pacletname", \
"MachineLearning`BuiltIn`PackagePrivate`p$", \
"MachineLearning`BuiltIn`PackagePrivate`result", \
"MachineLearning`BuiltIn`PackagePrivate`result$", \
"MachineLearning`BuiltIn`PackagePrivate`tmp", \
"MachineLearning`BuiltIn`PackagePrivate`tmp$"}

So I wondered, is there functionality already in mma to do this?

$\endgroup$
4
  • 1
    $\begingroup$ Is there anything in the CaffeLink package that helps with importing Caffe files into MMA? $\endgroup$
    – MarcoB
    Jun 8, 2016 at 21:19
  • $\begingroup$ Not really, it seems like it's only for linking... $\endgroup$
    – M.R.
    Jun 9, 2016 at 2:24
  • $\begingroup$ I think maybe you can first convert caffe model into mxnet model and then use ImportMXNetModel to import that. $\endgroup$ Dec 9, 2016 at 20:44
  • $\begingroup$ I didn't think there's no robust way to do that @xslittlegrass $\endgroup$
    – M.R.
    Dec 9, 2016 at 20:53

1 Answer 1

4
$\begingroup$

It seems that the caffe prototxt file can be imported into Mathematica through the MXNet converter.

We first convert the caffe network definition files into MXNet files using the caffe to MXNet converter

python convert_model.py VGG_ILSVRC_16_layers_deploy.prototxt VGG_ILSVRC_16_layers.caffemodel vgg16

Then we can load the MXNet files using ImportMXNetModel

Needs["MXNetLink`"]
ImportMXNetModel["vgg16-symbol.json","vgg16-0001.params"]

enter image description here

Here is the original caffe network visualized in netscope.

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.