daily pastebin goal
89%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #pragma once
  5. #define INCOUNT 100
  6. #define NEUROCOUNT 2
  7. #define it 20
  8.  
  9. class neuron
  10. {
  11. public:
  12.     neuron(int in);
  13.     double* x;//[INCOUNT+1];//âõîäûå ñèãíàëû
  14.     double* w;//[INCOUNT+1];//âåñà
  15.     double sum;
  16.     double axon_out;//âûâîä àêñîíà
  17.     double nu;//ñêîðîñòü îáó÷åíèÿ
  18.     neuron* next;
  19. };
  20.  
  21. neuron::neuron(int in)//êîë-âî íåéðîíîâ, ñ êîòîðûìè ñâÿçàí äàííûé íåéðîí - äëÿ fully connected net
  22. {
  23.   x=new double[in];
  24.   w=new double[in];
  25.   sum=0;
  26.   axon_out=0;
  27.   nu=1;
  28.   for(int i=0; i<in; i++)
  29.   {
  30.     x[i]=0;
  31.     w[i]=1;
  32.   }
  33. }
  34.  
  35. class neuro_net
  36. {
  37. public:
  38.     neuro_net(int layer_count, int* layer_inf);
  39.     double axon_func(double x);
  40.     double axon_func_der(double x);
  41.     void teach_backpropagation();
  42.     int process();
  43.     void explore_net();
  44.     neuron** layers;
  45. };
  46.  
  47. neuro_net::neuro_net(int layer_count, int* layer_inf)
  48. {
  49.   //ñîçäàäèì òðåáóåìóþ ñåòü
  50.   neuron* list[layer_count];
  51.   neuron* c; neuron* n;
  52.   int count=0, temp,temp1=0;
  53.   layers=list;
  54.  
  55.  
  56.   for(int i=0; i<layer_count; i++, count++)
  57.   {
  58.     if(i==0)temp=INCOUNT; else temp=layer_inf[i-1];
  59.     cout<<"temp== "<<temp<<'\n';
  60.     c=new neuron(temp);
  61.     cout<<"LIST "<<list<<'\n';
  62.    
  63.     for(int k=0; k<layer_inf[i]; k++)
  64.     {
  65.       if(k==0){list[count]=c;}
  66.       cout<<"list[count]== "<<*(&list[count])<<' '<<*(&layers[count])<<'\n';
  67.       /*for(neuron* g=(neuron*)list; temp1<3; temp1++)
  68.       {
  69.         cout<<"in list "<<g<<'\n';
  70.         g++;
  71.       } */
  72.      
  73.       (*c).axon_out=0;
  74.       (*c).sum=0;
  75.       (*c).nu=1;
  76.  
  77.       n=new neuron(temp);
  78.       if(k==layer_inf[i]-1)n=0;
  79.       (*c).next=n;
  80.       cout<<"creating neuron "<<k<<" at layer "<<count<<" C== "<<c<<" N== "<<(*c).next<<'\n';
  81.       c=n;
  82.     }
  83.     temp1=0;
  84.     delete n;
  85.     delete c;
  86.   }
  87. }
  88.  
  89.  
  90. void neuro_net::explore_net()
  91. {
  92.   //îñìàòðèâàåì íåéðîííóþ ñåòü
  93.   int l=0,c=0;
  94.   cout<<'\n';
  95.   for(l; l<3; l++)
  96.   {
  97.   for(neuron* m=*(&layers[l]); m!=0; m=(*m).next)
  98.   {
  99.     cout<<"neuron #"<<c<<' '<<"at layer "<<l<<" it's addr== "<<m<<" next mem at "<<(*m).next<<'\n';
  100.     system("PAUSE");
  101.     c++;
  102.   }
  103.   c=0;
  104. }
  105. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top