Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. class SSN
  8. {
  9. private:
  10. double x1,x2,x3;
  11. double y1,y2;
  12. double *wagi;
  13. public:
  14. SSN();
  15. ~SSN();
  16. double getx();
  17. void set_x(double x1, double x2,double x3);
  18. double neuron_3();
  19. };
  20. SSN::SSN()
  21. {
  22. this->x1=x1;
  23. this->x2=x2;
  24. this->x3=x3;
  25.  
  26. this-> wagi=new double[19];
  27.  
  28. }
  29. SSN::~SSN()
  30. {
  31.  
  32. }
  33. double SSN::getx()
  34. {
  35. return this->x1&&x2&&x3;
  36. }
  37. void SSN::set_x(double x1, double x2,double x3)
  38. {
  39. this->x1=x1;
  40. this->x2=x2;
  41. this->x3=x3;
  42.  
  43. }
  44.  
  45. double SSN::neuron_3()
  46. {
  47. for(int i=0;i<19;i++)
  48. {
  49. double x = ((double)rand()/(RAND_MAX));
  50. wagi[i]=x;
  51. }
  52.  
  53. double pierwsza_1,pierwsza_2,pierwsza_3,druga_1,druga_2, wyjscie_1,wyjscie_2,beta=0.5;
  54.  
  55. pierwsza_1=x1*wagi[0]+x2*wagi[1]+x3*wagi[2];
  56. pierwsza_2=x1*wagi[3]+x2*wagi[4]+x3*wagi[5];
  57. pierwsza_3=x1*wagi[6]+x2*wagi[7]+x3*wagi[8];
  58.  
  59. druga_1=pierwsza_1*wagi[9]+pierwsza_2*wagi[10]+pierwsza_3*wagi[11];
  60. druga_2=pierwsza_1*wagi[12]+pierwsza_2*wagi[13]+pierwsza_3*wagi[14];
  61.  
  62. wyjscie_1=druga_1*wagi[15]+druga_2*wagi[16];
  63. wyjscie_2=druga_1*wagi[17]+druga_2*wagi[18];
  64. this->y1=wyjscie_1;
  65. this->y2=wyjscie_2;
  66. cout<< "Fynkcja liniowa: Wyj1: "<<y1<<" "<<"Wyj2: "<<y2;
  67. if (y1<0) {
  68. cout<< "Funkcja progowa unipolarna: Wyj1: -1 ";
  69. if (y2<0) {
  70. cout<<"Wyj2: -1";
  71. } else {
  72. cout<<"Wyj2: 1";
  73. }
  74. } else if (y1>=0) {
  75. cout<<endl<< "Funkcja progowa unipolarna: Wyj1: 1 ";
  76. if (y2<0) {
  77. cout<<"Wyj2: -1";
  78. } else {
  79. cout<<"Wyj2: 1";
  80. }
  81. }
  82. cout<<endl;
  83. cout<< "Funkcja sigmoidalna unipolarna: Wyj1: "<<(1/(1+exp(-beta*y1)))<<" Wyj2: "<<(1/(1+exp(-beta*y2)));
  84. cout<<endl;
  85. return 0;
  86. }
  87.  
  88.  
  89. int main()
  90. {
  91. double x1,x2,x3;
  92. cin>>x1>>x2>>x3;
  93. SSN a;
  94. a.getx();
  95. a.set_x(x1,x2,x3);
  96. a.neuron_3();
  97.  
  98. return 0;
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement