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

📄 main_model.m

📁 Standard model object recognition matlab code
💻 M
字号:
function resp = main_model (stim,f_all,s_all,o_all,varargin)% FUNCTION resp = main_model (stim,f_all,s_all,o_all,varargin)%% This function computes and returns all the activities of the% units in the model for a given stimulus.  The activities of the% units are determined by the stimulus and the connectivity% (f_all), the mixing of scales (s_all), and operation (o_all),% along with the responses from the previous layers.%% varargin is used to specify from which layer to start% processing.  In other words, we can compute the response of% higher layers based on some saved response of an earlier layer.%% Note we designate different layers in the order of%  [S1 C1 S2b C2b S2 C2 S3 C3 VTU],% Therefore, we need to make sure to branch into main route or% bypass route appropropriately.global all_quanta;resp       = [];prev_layer = stim;if length(varargin) > 0  start_layer = varargin{1};else  start_layer = 1;endend_layer = length(fieldnames(f_all));if start_layer>1 & ~isstruct(prev_layer)  error('Input to the model is not quite right.');endfor curr_layer = start_layer:end_layer    % Display the progress.  %fprintf(['\b' num2str(curr_layer)]);    f_str = ['f' num2str(curr_layer)];  % Use the broken up filters.  See main_model_load_save.m  %load(['Filt_f' num2str(curr_layer)]);  %load(['Filt_s' num2str(curr_layer)]);  %f = f_alone;  %s = s_alone;  %m = m_alone;    if ~isstruct(getfield(f_all,f_str))    error('Filter is not defined.');  end    o = o_all(curr_layer,:);  % Branch into main routes, when bypass computation is also  % present, because prev_layer for the main route is C1  % response, not the response from C2b.    %  % Cases when level = [1 1 1 1 1 ...] or [0 0 1 1 1 ...].  % It should be okay when level = [0 0 0 0 1 ...]  if (curr_layer==5) % Branch point    if (start_layer==5) | (start_layer==3)      % Case [0 0 1 1 1 ...] or       % Case [0 0 0 0 1 ...]      prev_layer = stim; % stim must be resp from layer 2.    else           % Case [1 1 1 1 1 ...] or      % Case [1 1 0 0 1 ...]      prev_layer = getfield(resp, 'r2');    end  end    % Rescale the response, using sigmoid.  Note that we rescale  % prev_layer, not next_layer.  This allows the saving of the  % responses before the sigmoid transfer function, and makes it  % easy to adjust the sigmoid parameters.  Note that  % init_sigmoid_def is called to obtain the parameters from the  % previous layer.  [sigmoid_a, sigmoid_b] = init_sigmoid_def(curr_layer-1);  if sigmoid_a > 0    for ss = 1:length(fieldnames(prev_layer));      p_tmp = getfield(prev_layer, ['s' num2str(ss)]);      p_tmp = 1./(1+exp(-sigmoid_a.*(p_tmp-sigmoid_b)));       prev_layer = setfield(prev_layer,['s' num2str(ss)],p_tmp);    end  end  % Get next layer in the model  next_layer = comp_get_next_layer(prev_layer, ...      getfield(f_all,f_str), o);  % Mixing scales.  m = getfield (s_all, ['m' num2str(curr_layer)]);  if max(m) > 0     next_layer = comp_mix_scales(next_layer, ...	m, getfield(s_all,f_str),o);    end  % Quantize responses.  num_quanta = all_quanta(curr_layer);  next_layer = aux_quantize_resp(next_layer,num_quanta);    prev_layer = next_layer;  % Save the response.  resp = setfield(resp,['r' num2str(curr_layer)],next_layer);end

⌨️ 快捷键说明

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