⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aux_get_dummy_resp.m

📁 Standard model object recognition matlab code
💻 M
字号:
function [r all_size] = aux_get_dummy_resp (layer,stim_size,all_oper,varargin)% FUNCTION [r all_size] = aux_get_dummy_resp (layer)%% Based on the information given in init_filter_def and stim_size,% calculate the size of a given layer, which will depend on the% size of the previous layers.  Return a dummy structure r with the% correct size.%% If the 3-d matrix is wanted (instead of 2-d), set the number of% features in varargin{1} = 0.% If the response before mixing scale is needed, set varargin{2} = 0.if size(stim_size,1) ~= 2  stim_size = stim_size';end[a,b,c,d] = init_filter_def(1);num_scale_l0 = a;% all_size will keep track of all sizes at different layers, in 2% (x and y) by number of scales matrices.all_size = [];all_size = setfield(all_size, 'Layer0', ...    repmat(stim_size,[1,num_scale_l0]));for i = 1:layer   if i~=5      prev_size = getfield(all_size,['Layer' num2str(i-1)]);   else      % for C2 layer      prev_size = getfield(all_size,'Layer2');         end  % Get the definition of filters.  [a,b,c,d] = init_filter_def(i);  f_size  = b(1:2,:); % filter sizes.  shifts = c; % shift of convolution window.  m = d; % see filt_scalemixing.m.  next_size = zeros(2,a); % x and y dimensions x num scale.  next_size_new = zeros(2,max(m)); % x and y dimensions x num scale.  for s = 1:a % loop thru scales    % For some operations, the prev layer is cropped or    % zero-padded.    x = zeros(prev_size(1,s),prev_size(2,s));    x = comp_crop_or_zeropad(x,f_size(:,s),c(s),all_oper(i,:));    next_size(:,s) = (size(x)'-f_size(:,s))/c(s) + 1;    if (next_size(:,s)-floor(next_size(:,s)))~=0      error('Border crop/pad did not work well.');    end  end    % Now becase of scale mixing, not all next_siz will be available  % for the next size.  See filt_scalemixing.m  for m_idx = 1:max(m)    which_scale = find(m==m_idx);    next_size_new(:,m_idx) = max(next_size(:,which_scale),[],2);  end  all_size = setfield(all_size,['Layer' num2str(i)],next_size_new);end% Now prepare the dummy response.if length(varargin)>0  num_feature = varargin{1};  if length(varargin)>1    % Response before mixing scale is wanted.    next_size_new = next_size;  else    % Mix the scale.  endelse  num_feature = 1;endr = [];for s = 1:size(next_size_new,2)  r_tmp = zeros(next_size_new(1,s),next_size_new(2,s),num_feature);  r = setfield(r,['s' num2str(s)],r_tmp);end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -