hopfield神经网络

%% Hopfield神经网络——数字识别
%% 清空环境变量
clc
clear
%% 数据导入
load data1 array_one
load data2 array_two
load data3 three
load data4 four
load data5 five
load data6 six
load data7 seven
load data8 eight
load data9 nine
%% 训练样本(目标向量)
 T=[array_one;array_two;three;four;five;six;seven;eight;nine]';
%% 创建网络
 net=newhop(T);
%% 数字1和2的带噪声数字点阵(固定法)
% load data1_noisy noisy_array_one
% load data2_noisy noisy_array_two
%% 数字1和2的带噪声数字点阵(随机法)
noisy_array_one=array_one;
noisy_array_two=array_two;
noisy_array_three=three;
noisy_array_four=four;
noisy_array_five=five;
noisy_array_six=six;
noisy_array_seven=seven;
noisy_array_eight=eight;
noisy_array_nine=nine;
for i=1:100
    a=rand;
    if a<0.01
       noisy_array_one(i)=-array_one(i);
       noisy_array_two(i)=-array_two(i);
       noisy_array_three(i)=-three(i);
       noisy_array_four(i)=-four(i);
       noisy_array_five(i)=-five(i);
       noisy_array_six(i)=-six(i);
       noisy_array_seven(i)=-seven(i);
       noisy_array_eight(i)=-eight(i);
       noisy_array_nine(i)=-nine(i);
    end
end
%% 数字识别
noisy_one={(noisy_array_one)'};
identify_one=sim(net,{10,10},{},noisy_one);
identify_one{10}';

noisy_two={(noisy_array_two)'};
identify_two=sim(net,{10,10},{},noisy_two);
identify_two{10}';

noisy_three={(noisy_array_three)'};
identify_three=sim(net,{10,10},{},noisy_three);
identify_three{10}';

noisy_four={(noisy_array_four)'};
identify_four=sim(net,{10,10},{},noisy_four);
identify_four{10}';

noisy_five={(noisy_array_five)'};
identify_five=sim(net,{10,10},{},noisy_five);
identify_five{10}';

noisy_six={(noisy_array_six)'};
identify_six=sim(net,{10,10},{},noisy_six);
identify_six{10}';

noisy_seven={(noisy_array_seven)'};
identify_seven=sim(net,{10,10},{},noisy_seven);
identify_seven{10}';

noisy_eight={(noisy_array_eight)'};
identify_eight=sim(net,{10,10},{},noisy_eight);
identify_eight{10}';

noisy_nine={(noisy_array_nine)'};
identify_nine=sim(net,{10,10},{},noisy_nine);
identify_nine{10}';
%% 结果显示
Array_one=imresize(array_one,20);
subplot(3,9,1)
imshow(Array_one)
title('标准(数字1)') 

Array_two=imresize(array_two,20);
subplot(3,9,2)
imshow(Array_two)
title('标准(数字2)') 

Array_three=imresize(three,20);
subplot(3,9,3)
imshow(Array_three)
title('标准(数字3)')

Array_four=imresize(four,20);
subplot(3,9,4)
imshow(Array_four)
title('标准(数字4)')

Array_five=imresize(five,20);
subplot(3,9,5)
imshow(Array_five)
title('标准(数字5)')

Array_six=imresize(six,20);
subplot(3,9,6)
imshow(Array_six)
title('标准(数字6)')

Array_seven=imresize(seven,20);
subplot(3,9,7)
imshow(Array_seven)
title('标准(数字7)')

Array_eight=imresize(eight,20);
subplot(3,9,8)
imshow(Array_eight)
title('标准(数字8)')

Array_nine=imresize(nine,20);
subplot(3,9,9)
imshow(Array_nine)
title('标准(数字9)')

subplot(3,9,10)
Noisy_array_one=imresize(noisy_array_one,20);
imshow(Noisy_array_one)
title('噪声(数字1)') 

subplot(3,9,11)
Noisy_array_two=imresize(noisy_array_two,20);
imshow(Noisy_array_two)
title('噪声(数字2)')

subplot(3,9,12)
Noisy_array_three=imresize(noisy_array_three,20);
imshow(Noisy_array_three)
title('噪声(数字3)')

subplot(3,9,13)
Noisy_array_four=imresize(noisy_array_four,20);
imshow(Noisy_array_four)
title('噪声(数字4)')

subplot(3,9,14)
Noisy_array_five=imresize(noisy_array_five,20);
imshow(Noisy_array_five)
title('噪声(数字5)')

subplot(3,9,15)
Noisy_array_six=imresize(noisy_array_six,20);
imshow(Noisy_array_six)
title('噪声(数字6)')

subplot(3,9,16)
Noisy_array_seven=imresize(noisy_array_seven,20);
imshow(Noisy_array_seven)
title('噪声(数字7)')

subplot(3,9,17)
Noisy_array_eight=imresize(noisy_array_eight,20);
imshow(Noisy_array_eight)
title('噪声(数字8)')

subplot(3,9,18)
Noisy_array_nine=imresize(noisy_array_nine,20);
imshow(Noisy_array_nine)
title('噪声(数字9)')

subplot(3,9,19)
imshow(imresize(identify_one{10}',20))
title('识别(数字1)')

subplot(3,9,20)
imshow(imresize(identify_two{10}',20))
title('识别(数字2)')

subplot(3,9,21)
imshow(imresize(identify_three{10}',20))
title('识别(数字3)')

subplot(3,9,22)
imshow(imresize(identify_four{10}',20))
title('识别(数字4)')

subplot(3,9,23)
imshow(imresize(identify_five{10}',20))
title('识别(数字5)')

subplot(3,9,24)
imshow(imresize(identify_six{10}',20))
title('识别(数字6)')

subplot(3,9,25)
imshow(imresize(identify_seven{10}',20))
title('识别(数字7)')

subplot(3,9,26)
imshow(imresize(identify_eight{10}',20))
title('识别(数字8)')

subplot(3,9,27)
imshow(imresize(identify_nine{10}',20))
title('识别(数字9)')
%%

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值