1 function layers = matcaffe_demo_weights(use_gpu)
2 % layers = matcaffe_demo_weights(use_gpu)
4 % Demo of how to extract network parameters ("weights") using the matlab
8 % use_gpu 1 to use the GPU, 0 to use the CPU
11 % layers struct array of layers and their weights
13 % You may need to do the following before you start matlab:
14 % $ export LD_LIBRARY_PATH=/opt/intel/mkl/lib/intel64:/usr/local/cuda/lib64
15 % $ export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
16 % Or the equivalent based on where things are installed on your system
18 % init caffe network (spews logging info)
19 if caffe('is_initialized') == 0
20 model_def_file = '../../examples/imagenet_deploy.prototxt';
21 model_file = '../../examples/alexnet_train_iter_470000';
22 caffe('init', model_def_file, model_file);
25 % set to use GPU or CPU
26 if exist('use_gpu', 'var') && use_gpu
27 caffe('set_mode_gpu');
29 caffe('set_mode_cpu');
33 caffe('set_phase_test');
35 layers = caffe('get_weights');