steniu01 | bee466b | 2017-06-21 16:45:41 +0100 | [diff] [blame] | 1 | /** |
| 2 | @page data_import Importing data from existing models |
| 3 | |
| 4 | @tableofcontents |
| 5 | |
| 6 | @section caffe_data_extractor Extract data from pre-trained caffe model |
| 7 | |
| 8 | One can find caffe <a href="https://github.com/BVLC/caffe/wiki/Model-Zoo">pre-trained models</a> on |
| 9 | caffe's official github repository. |
| 10 | |
| 11 | The caffe_data_extractor.py provided in the @ref scripts folder is an example script that shows how to |
| 12 | extract the hyperparameter values from a trained model. |
| 13 | |
| 14 | @note complex networks might require alter the script to properly work. |
| 15 | |
| 16 | @subsection how_to How to use the script |
| 17 | |
| 18 | Install caffe following <a href="http://caffe.berkeleyvision.org/installation.html">caffe's document</a>. |
| 19 | Make sure the pycaffe has been added into the PYTHONPATH. |
| 20 | |
| 21 | Download the pre-trained caffe model. |
| 22 | |
| 23 | Run the caffe_data_extractor.py script by |
| 24 | |
| 25 | ./caffe_data_extractor.py -m <caffe model> -n <caffe netlist> |
| 26 | |
| 27 | For example, to extract the data from pre-trained caffe Alex model to binary file: |
| 28 | |
| 29 | ./caffe_data_extractor.py -m /path/to/bvlc_alexnet.caffemodel -n /path/to/caffe/models/bvlc_alexnet/deploy.prototxt |
| 30 | |
| 31 | The script has been tested under Python2.7. |
| 32 | |
| 33 | @subsection result What is the expected ouput from the script |
| 34 | |
| 35 | If the script run succesfully, it prints the shapes of each layer onto the standard |
| 36 | output and generates *.dat files containing the weights and biases of each layer. |
| 37 | |
| 38 | The @ref arm_compute::utils::load_trained_data shows how one could load |
| 39 | the weights and biases into tensor from the .dat file by the help of Accessor. |
| 40 | */ |