简单神经网络代码1-2

类别:编程语言 点击:0 评论:0 推荐:
LOGICNERVECELL *NN::findNerveCell(U2 n) /*tmpnc 指向找到的神经元的前一个 *nc指向找到的那个*/

   LOGICNERVECELL *tmpnc;          
   if(*nc->nc->nerve_cell_num == n)    
   {                                                                     
        return(*tmpnc);                     
   }
   else if(*nv->next == NULL)
   {   
        *nc = frist_nc;  /*重新指向第一个*/ 
        return(NULL);
   }    
   else
   {   
        tmpnc = *nc;         
        *nc = *nc->next;       
        findNerveCell(n);    
   }  
   return(NULL);    
}    
NN::NN(U2 init)                                  

   INIT = init;
   n_cell = INIT;
   recycle_cell = 0;
   recycle = (LOGICNERVECELL *)(malloc(sizeof(LOGICNERVECELL))*MAX_RECYCLE);
  /*================================================================*/  
   *nc = (LOGICNERVECELL *)(malloc(sizeof(LOGICNERVECELL)));  
   *nc->nc = (NERVECELL*)(malloc(sizeof(NERVECELL))); 
   *nc->nc->nerve_cell_num = 1;
   *nc->nc->input = NULL;
   *nc->nc->output = NULL;
   frist_nc = *nc;          
   for(int i=2;i<=n_cell;i++)
   {  
       *nc->next = (LOGICNERVECELL *)(malloc(sizeof(LOGICNERVECELL)));
       *nc->next->nc = (NERVECELL*)(malloc(sizeof(NERVECELL)));
       if(i==(n_cell))
       {  
           *nc->next->nc->nerve_cell_num = i;
           *nc->next->nc->input = NULL;
           *nc->next->nc->output = NULL;
           *nc->next = NULL;          
       }
       else
       {                  
           *nc->next->nc->nerve_cell_num = i;
           *nc->next->nc->input = NULL;
           *nc->next->nc->output = NULL;
           *nc = *nc->next;
       }
   }   
   frist_nc = *nc;  /*重新指想第一个神经元*/ 
}
   
NN::~NN()       

  //释放所有占用的内寸
}                
void NN::addNerveCellByNum(U2 n)  /*n为增加多少个*/
{          
      for(int i=1;i<=n;i++)                             
      {
            *nc->next = (LOGICNERVECELL *)(malloc(sizeof(LOGICNERVECELL)));
            *nc->next->nc = (NERVECELL*)(malloc(sizeof(NERVECELL)));
            if(i==n)
            {  
                *nc->next->nc->nerve_cell_num = n_cell;
                *nc->next->nc->input = NULL;
                *nc->next->nc->output = NULL;
                *nc->next = NULL;        
            }
            else
            {                  
                *nc->next->nc->nerve_cell_num = i+n_cell;
                *nc->next->nc->input = NULL;
                *nc->next->nc->output = NULL;
                *nc = *nc->next;
            }    
      }   
      *nc = frist_nc; /*重新指想第一个神经元*/ 
      n_cell = n_cell+n;  
      return;    
}    

本文地址:http://com.8s8s.com/it/it22443.htm