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

📄 test_oper.m

📁 Standard model object recognition matlab code
💻 M
字号:
function test_oper% FUNCTION test_oper% % Test the operation routines (comp_get_next_layer.m) in the codes.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1D functionx_range = [0:0.01:1];x1 = zeros(length(x_range), 1, 1);x1(:,1,1) = x_range;f = [];f = setfield(f, 'f1_s1', 0.5);f = setfield(f, 'f2_s1', 1);f = setfield(f, 'i1_s1', [1 0]);f = setfield(f, 'i2_s1', [1 0]);f = setfield(f, 'i3_s1', [1 0]);f = setfield(f, 'size_s1', [1 1 1 1]);f = setfield(f, 'shift_s1', 1);yg = comp_get_next_layer (x1, f, 'gaussf');y = comp_get_next_layer (x1, f, 'normdp');subplot(2,1,1);plot(x_range, yg.s1)subplot(2,1,2);plot(x_range, y.s1)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2D functionx_range  = [0:0.01:1];%x_range = [0:0.1:1];[x1,x2]  = ndgrid(x_range);x        = ones([size(x1) 2]);x(:,:,1) = x1;x(:,:,2) = x2;f = [];f = setfield(f, 'f1_s1', [0.5 0.3]');f = setfield(f, 'f2_s1', [1   1  ]');f = setfield(f, 'i1_s1', [1 1 0]');f = setfield(f, 'i2_s1', [1 1 0]');f = setfield(f, 'i3_s1', [1 2 0]');f = setfield(f, 'size_s1', [1 1 2 1]);f = setfield(f, 'shift_s1', 1);yg = comp_get_next_layer (x, f, 'gaussf');y  = comp_get_next_layer (x, f, 'normdp');clim = [0 1];subplot(3,1,1); imagesc(x_range, x_range, yg.s1',clim);axis xy square;title(num2str(max(max(yg.s1))));subplot(3,1,2); imagesc(x_range, x_range, y.s1',clim);axis xy square;title(num2str(max(max(y.s1))));%y_corr = y.s1/0.5;y_corr = y.s1;aa = 1/var(y_corr(find(y_corr>0.75)));bb = mean(y_corr(find(y_corr>0.75)));aa = 1/std(y_corr(:));bb = mean(y_corr(:));bb = max(y_corr(:));y_corr = 1./(1+exp(-aa*(y_corr-bb)));subplot(3,1,3); imagesc(x_range, x_range, y_corr',clim);axis xy square;title(num2str(max(max(y.s1))));%plot(x_range, y.s1)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% N-D functiond        = 10;num_samp = 1000;w1       = rand(d,1);w2       = ones(d,1);x        = rand(num_samp,1,d);f = [];f = setfield(f, 'f1_s1', w1);f = setfield(f, 'f2_s1', w2);f = setfield(f, 'i1_s1', [ones(d,1); 0]);f = setfield(f, 'i2_s1', [ones(d,1); 0]);f = setfield(f, 'i3_s1', [1:d 0]');f = setfield(f, 'size_s1', [1 1 d 1]);f = setfield(f, 'shift_s1', 1);yg = comp_get_next_layer (x, f, 'gaussf');y  = comp_get_next_layer (x, f, 'normdp');subplot(3,1,1);y_corr = y.s1;plot(yg.s1, y_corr, '.'); axis([0 1 0 1], 'square');xlabel('Gauss');ylabel('NSP');subplot(3,1,2);aa     = 1/std(y_corr(:));bb     = mean(y_corr(:));bb     = 0.49;plot([0:0.01:1], 1./(1+exp(-aa*([0:0.01:1]-bb))));axis square;subplot(3,1,3);y_corr = 1./(1+exp(-aa*(y_corr-bb)));plot(yg.s1, y_corr, '.'); axis([0 1 0 1], 'square');x_ref = 10; % some random pointsdist  = sum((x-repmat(x(x_ref,:,:), [num_samp, 1 1])).^2,3);r_dif = y_corr-y_corr(x_ref);rg_dif = yg.s1-yg.s1(x_ref);subplot(3,1,1);plot(dist, r_dif, '.');subplot(3,1,2);plot(dist, rg_dif, '.');subplot(3,1,3);plot(r_dif, rg_dif, '.');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2D plus N-D featuresd = 10; % 10 featuresx = rand(10,10,d);f_4D = [];f_4D(:,:,:,1) = x(2+[1:3],3+[1:3],:);f_4D(:,:,:,2) = x(4+[1:3],3+[1:3],:);f_4D(:,:,:,3) = x(1+[1:3],1+[1:3],:);f = [];f = filt_package(f,f_4D,ones(size(f_4D)),1,'s1');y = comp_get_next_layer (x, f, 'gaussf');

⌨️ 快捷键说明

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