Clang error: no such file or directory: '$(STATIC_NAME)' #5667
Open
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
82965f0
add set_weights in matcaffe.cpp to transplant parameters
xianjiec da2913b
add save function in matcaffe.cpp to save net into file
xianjiec 7420100
add matlab net surgery demo
xianjiec b9f683d
Merge branch 'dev' of https://github.com/BVLC/caffe into dev
xianjiec 450b4cb
add necessary check in net surgery demo
xianjiec dc793b0
changed tabs for spaces
xianjiec 16c662b
add net has been initialized before get_weights
xianjiec e2d0e80
add conv_forward in matcaffe.cpp to enable fully-convolutional infere…
xianjiec
Jump to file or symbol
Failed to load files and symbols.
| @@ -0,0 +1,66 @@ | ||
| +% ------------------------------------------------------------------------ | ||
| +% net_surgery_demo | ||
| +% ------------------------------------------------------------------------ | ||
| +caffe_root = '../../'; | ||
| +deploy_file = fullfile(caffe_root, 'models/bvlc_reference_caffenet/deploy.prototxt'); | ||
| +model_file = fullfile(caffe_root, 'models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel'); | ||
| +deploy_conv_file = fullfile(caffe_root, 'examples/imagenet/bvlc_caffenet_full_conv.prototxt'); | ||
| + | ||
| +if ~exist(model_file, 'file') | ||
| + fprintf('Please download caffe reference net first\n'); | ||
| + return; | ||
| +end | ||
| + | ||
| +%% get weights in the net with fully-connected layers | ||
| +caffe('reset'); | ||
| +caffe('init', deploy_file, model_file); | ||
| +fc_weights = caffe('get_weights'); | ||
| +% print blob dimensions | ||
| +fc_names = {'fc6', 'fc7', 'fc8'}; | ||
| +fc_layer_ids = zeros(3, 1); | ||
| +for ii = 1:numel(fc_names) | ||
| + lname = fc_names{ii}; | ||
| + for jj = 1:numel(fc_weights) | ||
| + if (strcmp(fc_weights(jj).layer_names, lname)) | ||
| + fprintf('%s weights are ( %s) dimensional and biases are ( %s) dimensional\n', ... | ||
| + lname, sprintf('%d ', size(fc_weights(jj).weights{1})), ... | ||
| + sprintf('%d ', size(fc_weights(jj).weights{2}))); | ||
| + fc_layer_ids(ii) = jj; | ||
| + end | ||
| + end | ||
| +end | ||
| + | ||
| +%% get weights in full-convolutional net | ||
| +caffe('reset'); | ||
| +caffe('init', deploy_conv_file, model_file); | ||
| +conv_weights = caffe('get_weights'); | ||
| +% print corresponding blob dimensions | ||
| +conv_names = {'fc6-conv', 'fc7-conv', 'fc8-conv'}; | ||
| +conv_layer_ids = zeros(3, 1); | ||
| +for ii = 1:numel(conv_names) | ||
| + lname = conv_names{ii}; | ||
| + for jj = 1:numel(conv_weights) | ||
| + if (strcmp(conv_weights(jj).layer_names, lname)) | ||
| + fprintf('%s weights are ( %s) dimensional and biases are ( %s) dimensional\n', ... | ||
| + lname, sprintf('%d ', size(conv_weights(jj).weights{1})), ... | ||
| + sprintf('%d ', size(conv_weights(jj).weights{2}))); | ||
| + conv_layer_ids(ii) = jj; | ||
| + end | ||
| + end | ||
| +end | ||
| + | ||
| +%% tranplant paramters into full-convolutional net | ||
| +trans_params = struct('weights', cell(numel(conv_names), 1), ... | ||
| + 'layer_names', cell(numel(conv_names), 1)); | ||
| +for ii = 1:numel(conv_names) | ||
| + trans_params(ii).layer_names = conv_names{ii}; | ||
| + weights = cell(2, 1); | ||
| + weights{1} = reshape(fc_weights(fc_layer_ids(ii)).weights{1}, size(conv_weights(conv_layer_ids(ii)).weights{1})); | ||
| + weights{2} = reshape(fc_weights(fc_layer_ids(ii)).weights{2}, size(conv_weights(conv_layer_ids(ii)).weights{2})); | ||
| + trans_params(ii).weights = weights; | ||
| +end | ||
| +caffe('set_weights', trans_params); | ||
| +%% save | ||
| +fully_conv_model_file = fullfile(caffe_root, 'examples/imagenet/bvlc_caffenet_full_conv.caffemodel'); | ||
| +caffe('save', fully_conv_model_file); | ||
| + |