Matlab Hopfield网络用于图像模式识别的不良结果
我在matlab中编写了一个用Hopfield网络进行图像模式识别的代码。 我的代码没有错误。因为我使用字母模式,所以得到了很好的结果。但当我使用数字模式时,结果是不同的。为此,我对六个数字使用了两种不同的模式。 如果可能的话,请引导我Matlab Hopfield网络用于图像模式识别的不良结果,matlab,image-processing,Matlab,Image Processing,我在matlab中编写了一个用Hopfield网络进行图像模式识别的代码。 我的代码没有错误。因为我使用字母模式,所以得到了很好的结果。但当我使用数字模式时,结果是不同的。为此,我对六个数字使用了两种不同的模式。 如果可能的话,请引导我 matlab % Retrieval phase for input = 1:6 figure(input+1); set(gcf,'Name','Testing Covergence from 2nd input to 1st input
matlab
% Retrieval phase
for input = 1:6
figure(input+1);
set(gcf,'Name','Testing Covergence from 2nd input to 1st input')
subplot(4,5,2)
Imageplot1(P(:,input),Dimension,Dimension);
xlabel('1st pat')
subplot(4,5,4)
Imageplot1(P2(:,input),Dimension,Dimension)
xlabel('2nd pat')
update = 400 ; % iritation to show
Input = P2(:,input);
plot='on';
%% my check
Out = zeros(Dime,1) ;
Counter = 1 ;
for j = 1:Dime
Out(j) = sign(W(j,:)*Input); %Convergence Condition
if Out(j)~= Input(j)
Input(j) = Out (j) ;
Iteration(:,Counter) = Input ;
Counter = Counter + 1 ;
end
end
It_n = ceil ( Counter / update ) ;
figure (input + 1)
for n = 1 : It_n
if (n * update) < (Counter - 1)
subplot(4,5,5+n)
Imageplot1(Iteration(:,n * update),Dimension,Dimension);
pause(0.3);
end
end
subplot(4,5,18)
Imageplot1(Iteration(:,end),Dimension,Dimension);
xlabel('final Iteration')
clear Iteration
end
matlab
%恢复阶段
对于输入=1:6
数字(输入+1);
集合(gcf、'Name'、'Testing convergence from second input to first input')
子地块(4,5,2)
Imageplot1(P(:,输入),尺寸,尺寸);
xlabel(“第一页”)
子批次(4,5,4)
Imageplot1(P2(:,输入),标注,标注)
xlabel(“第二部分”)
更新=400;%虹彩
输入=P2(:,输入);
策划;
%%我的支票
Out=零(一角,1);
计数器=1;
对于j=1:Dime
输出(j)=符号(W(j,:)*输入);%收敛条件
如果输出(j)~=输入(j)
输入(j)=输出(j);
迭代(:,计数器)=输入;
计数器=计数器+1;
结束
结束
It\u n=ceil(计数器/更新);
图(输入+1)
对于n=1:It\n
如果(n*更新)<(计数器-1)
子地块(4,5,5+n)
Imageplot1(迭代(:,n*更新),尺寸,尺寸);
暂停(0.3);
结束
结束
子地块(4,5,18)
Imageplot1(迭代(:,结束),尺寸,尺寸);
xlabel(‘最终迭代’)
清晰迭代
结束