📄 hop_demo.m
字号:
% Demo of Hopfield network% Hugh Pasika 1997clcclfdisp('The Hopfield Network - Demo 1 - Pattern Recall')disp('----------------------------------------------')disp(' ')disp('This algorithm demonstates recall of a corrupted pattern.')disp('The user is prompted for the input pattern and the noise level ')disp('and well as an interval at which to show progress of the algorithm.')disp(' ')disp('Loading the digits.')load hop_datadisp(' ')disp('Hit a key to continue.')figure(1)hop_plotpats(P)set(gcf,'Name','Hopfield Network - Input Patterns')set(gcf,'Position',[16 445 568 427])pausedisp(' ')%----------------- Calculate Weight Matrixdisp('Calculating the weight matrix.') W=hop_stor(P);%----------------- Select Input Patternpat=78;while pat<1 | pat> 8fprintf(1,'Select an input pattern to corrupt with noise according to\n')pat=input('the number under it (1 to 8): ');endfigure(1)set(gcf,'Position',[11 653 645 244])set(gcf,'Name','Hopfield Network - Recall')clfsubplot(1,3,1)hop_plotdig(P(:,pat),12,10,'Input Pattern')%------------------ Input bit flip probabilitypr=100; % dummy variable to get loop startedwhile (pr <= 0) | (pr >= 1),pr=input('Enter the probability of flipping a bit (0 to 1): ');endtest_pat=hop_flip(P(:,pat),pr);subplot(1,3,2)hop_plotdig(test_pat,12,10)xlabel('Corrupted Pattern')%------------------ How often to view network stateu=100; % dummy variable to get loop startedwhile (u < 1) | (u > 10),u=input('How many iterations between viewing the network state (1 to 10): ');enddisp('OK. Entering the recall phase. ')subplot(1,3,3)[s,c,M]=hop_test(W,test_pat,u);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -