📄 learn_filters_load_save.m
字号:
function f = learn_filters_load_save (prev_dir,savefile,layer)% FUNCTION f = learn_filters_load_save (prev_dir,savefile,layer)% % This function returns the learned features, learned from% prev_dir, and save them in savefile. The input% "param" determines which set of learn parameters to choose in% init_learn_param.mglobal ON_CON;ON_CON = 10;% "layer" is a switch that determines the following parameters.init_learn_param; %learn_num_patch = 10; % number of patches per training image%learn_patch_siz = [3]; % size of patches (spatial dimension)%learn_num_afferents = 10; % number of afferents within the patch%learn_scales = [3]; % [1:8];%shift = 1;D = dir([prev_dir '/r_i*.mat']);f = [];disp(['Learning on ' num2str(length(D)) ' images: ' prev_dir]);for i = 1:length(D) fprintf('.'); % Display the progress if mod(i,50) == 0 fprintf('\n'); end % Find the response and retrieve the last layer. load ([prev_dir D(i).name]); X = r; % Tag with the first learn_scale. scale_tag = ['s' num2str(learn_scales(1))]; % Learn the snapshots and save. for which_scale = learn_scales Xs = getfield(X, scale_tag); if max(max(max(abs(Xs))))>0 % For non-blank images only [f1, f2] = learn_snapshots (Xs, learn_patch_siz(which_scale), ... learn_num_patch, learn_num_afferents); f2 = (double(f1>=ON_CON)); % Do f2 first. f1 = (double(f1-ON_CON)>=0).*(f1-ON_CON); % Check the dimension of learned filters, before returning the results. % This is for the case when we had learned only 1 feature. if size(f1,4) <= 1 f0 = zeros([size(f1) 1]); f0(:,:,:,1) = f1; f1 = f0; end if size(f2,4) <= 1 f0 = zeros([size(f2) 1]); f0(:,:,:,1) = f2; f2 = f0; end f_tmp = filt_package([],f1,f2,shift(which_scale), ... ['s' num2str(which_scale)]); % Merge with the previous filters if isstruct(f) % & isfield(f, ['f1_' scale_tag]) %f = aux_merge_filters(f,which_scale,f_tmp,which_scale,scale_tag); f = aux_merge_filters(f,learn_scales(1),f_tmp,which_scale,scale_tag); else f = f_tmp; end end endendfprintf('\n');save(savefile, 'f', 'learn_num_patch', 'learn_patch_siz', ... 'learn_num_afferents', 'learn_scales');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -