diff options
author | Ross Girshick <rbg@eecs.berkeley.edu> | 2013-12-20 14:39:22 -0800 |
---|---|---|
committer | Evan Shelhamer <shelhamer@imaginarynumber.net> | 2014-03-19 19:12:57 -0700 |
commit | ba10066aff51f935f50ddba904ea34046433a79d (patch) | |
tree | 48ecae89ddf5ffc549a4d3e0e6d349f9511859f1 /matlab | |
parent | dee9ce76ffeb8296931c4268caedfb0f00f07925 (diff) | |
download | caffeonacl-ba10066aff51f935f50ddba904ea34046433a79d.tar.gz caffeonacl-ba10066aff51f935f50ddba904ea34046433a79d.tar.bz2 caffeonacl-ba10066aff51f935f50ddba904ea34046433a79d.zip |
demo on how to get net weights using the matlab interface
Diffstat (limited to 'matlab')
-rw-r--r-- | matlab/caffe/matcaffe_demo_weights.m | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/matlab/caffe/matcaffe_demo_weights.m b/matlab/caffe/matcaffe_demo_weights.m new file mode 100644 index 00000000..aae15593 --- /dev/null +++ b/matlab/caffe/matcaffe_demo_weights.m @@ -0,0 +1,35 @@ +function layers = matcaffe_demo_weights(use_gpu) +% layers = matcaffe_demo_weights(use_gpu) +% +% Demo of how to extract network parameters ("weights") using the matlab +% wrapper. +% +% input +% use_gpu 1 to use the GPU, 0 to use the CPU +% +% output +% layers struct array of layers and their weights +% +% You may need to do the following before you start matlab: +% $ export LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64:/usr/local/cuda/lib64 +% $ export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 +% Or the equivalent based on where things are installed on your system + +% init caffe network (spews logging info) +if caffe('is_initialized') == 0 + model_def_file = '../../examples/imagenet_deploy.prototxt'; + model_file = '../../examples/alexnet_train_iter_470000'; + caffe('init', model_def_file, model_file); +end + +% set to use GPU or CPU +if exist('use_gpu', 'var') && use_gpu + caffe('set_mode_gpu'); +else + caffe('set_mode_cpu'); +end + +% put into test mode +caffe('set_phase_test'); + +layers = caffe('get_weights'); |