[转载]离散Hopfield神经网络

离散Hopfield神经网络

原文链接https://blog.csdn.net/linuxcumt1/article/details/8597786












  
  
  1. % ------------------------standard number array-----------------------
  2. one=[ -1 -1 -1 -1 1 1 -1 -1 -1 -1; -1 -1 -1 -1 1 1 -1 -1 -1 -1;...
  3. -1 -1 -1 -1 1 1 -1 -1 -1 -1; -1 -1 -1 -1 1 1 -1 -1 -1 -1;...
  4. -1 -1 -1 -1 1 1 -1 -1 -1 -1; -1 -1 -1 -1 1 1 -1 -1 -1 -1;...
  5. -1 -1 -1 -1 1 1 -1 -1 -1 -1; -1 -1 -1 -1 1 1 -1 -1 -1 -1;...
  6. -1 -1 -1 -1 1 1 -1 -1 -1 -1; -1 -1 -1 -1 1 1 -1 -1 -1 -1];
  7. two=[ -1 1 1 1 1 1 1 1 1 -1; -1 1 1 1 1 1 1 1 1 -1;...
  8. -1 -1 -1 -1 -1 -1 -1 1 1 -1; -1 -1 -1 -1 -1 -1 -1 1 1 -1;...
  9. -1 1 1 1 1 1 1 1 1 -1; -1 1 1 1 1 1 1 1 1 -1;...
  10. -1 1 1 -1 -1 -1 -1 -1 -1 -1; -1 1 1 -1 -1 -1 -1 -1 -1 -1;...
  11. -1 1 1 1 1 1 1 1 1 -1; -1 1 1 1 1 1 1 1 1 -1];
  12. % ----------------------plot standard number figure-----------------
  13. ONE=imresize(one, 20);
  14. subplot( 3, 2, 1)
  15. imshow(ONE)
  16. title( 'stand number')
  17. TWO=imresize(two, 20);
  18. subplot( 3, 2, 2)
  19. imshow(TWO)
  20. title( 'stand number')
  21. % ----------------------create hopfield net--------------------------
  22. T=[one;two] ';
  23. net=newhop(T);
  24. % ------------------------------generate noise----------------------------
  25. % -------------------------noise array(fixed noise)--------------
  26. % no1=[-1 -1 -1 -1 1 1 -1 -1 -1 -1;-1 -1 -1 -1 1 -1 -1 -1 -1 -1;...
  27. % -1 -1 1 -1 1 1 -1 -1 -1 -1; -1 -1 -1 -1 1 1 1 -1 -1 -1;...
  28. % -1 -1 -1 -1 -1 1 -1 -1 -1 -1; -1 -1 -1 -1 1 1 -1 1 -1 -1;...
  29. % -1 -1 -1 -1 1 1 -1 -1 -1 -1; -1 1 -1 -1 1 1 -1 -1 -1 -1;...
  30. % -1 -1 -1 -1 -1 1 -1 -1 -1 -1; -1 -1 -1 -1 1 1 -1 -1 1 -1];
  31. %
  32. % no2=[-1 1 1 1 -1 1 1 -1 1 -1;-1 1 1 1 1 1 1 1 1 -1;...
  33. % -1 -1 1 -1 1 -1 -1 1 1 -1;-1 -1 -1 1 -1 1 -1 1 1 -1;...
  34. % -1 1 1 1 1 1 1 1 1 -1;-1 1 1 1 1 1 1 1 1 -1;...
  35. % -1 1 1 -1 -1 -1 -1 -1 -1 -1;-1 1 1 -1 -1 -1 -1 -1 -1 -1;...
  36. % -1 1 1 1 -1 1 1 1 1 -1;-1 1 1 -1 1 1 1 1 1 -1];
  37. % -----------------------noise array(rand noise)-----------------
  38. rand('state', 0);
  39. for i= 1: 100
  40. a=rand;
  41. if a< 0.1
  42. one(i)=-one(i);
  43. two(i)=-two(i);
  44. end
  45. end
  46. no1=one;
  47. no2=two;
  48. % -------------------------plot noisy figure---------------
  49. subplot( 3, 2, 3)
  50. NO1=imresize(no1, 20);
  51. imshow(NO1)
  52. title( 'noisy number')
  53. subplot( 3, 2, 4)
  54. NO2=imresize(no2, 20);
  55. imshow(NO2)
  56. title( 'noisy number')
  57. % --------------------------plot identify figure--------------
  58. noise1={(no1) '};
  59. tu1=sim(net,{10,50},{},noise1);
  60. tu1{50}'
  61. subplot( 3, 2, 5)
  62. imshow(imresize(tu1{ 50} ',20))
  63. title('identify number')
  64. noise2={(no2) '};
  65. tu2=sim(net,{10,50},{},noise2);
  66. tu2{50}'
  67. subplot( 3, 2, 6)
  68. imshow(imresize(tu2{ 50} ',20))
  69. title('identify number')
  70. web -browser http: //www.ilovematlab.cn/thread-30439-1-1.html


猜你喜欢

转载自blog.csdn.net/qq_36248632/article/details/90209416