Caffe Translator is a migration tool that helps developers migrate their existing Caffe code to MXNet and continue further development using MXNet. Note that this is different from the Caffe to MXNet model converter which is available here.
Caffe Translator takes the training/validation prototxt (example) and solver prototxt (example) as input and produces MXNet Python code (example) as output. The translated Python code uses MXNet Symbol and Module API to build the network, reads data from LMDB files (example), runs training and saves the trained model using the MXNet Module API (example).
Download the Caffe Translator from maven repository or build from source. Java Runtime Environment (JRE) is required to run the translator.
To translate train_val.prototxt
and solver.prototxt
to MXNet Python code, run the following command:
java -jar caffe-translator-<version>.jar --training-prototxt <train_val_prototxt_path> \ --solver <solver_prototxt_path> \ --output-file <output_file_path>
Example:
java -jar caffe-translator-0.9.1.jar --training-prototxt lenet_train_test.prototxt \ --solver lenet_solver.prototxt \ --output-file translated_code.py
Here is the list of command line parameters accepted by the Caffe Translator:
CaffeDataIter
to translate these layers to MXNet.Note: Translated code uses CaffeDataIter
to read from LMDB files. CaffeDataIter
requires the number of examples in LMDB file to be specified as a parameter. You can provide this information before translation using a #CaffeToMXNet
directive like shown below:
data_param { source: "data/mnist/mnist_train_lmdb" #CaffeToMXNet num_examples: 60000 batch_size: 64 backend: LMDB }
Following prerequisites are required to run the translated code:
Once prerequisites are installed, the translated Python code can be run like any other Python code:
Example:
python translated_code.py
Caffe Translator can currently translate the following layers:
* Uses CaffePlugin
If you want Caffe Translator to translate a layer that is not in the above list, please create an issue.