Ejemplo n.º 1
0
bool SnnsCLib::cc_UnitsHaveToBeConnected(int SpecialUnitNo,struct Unit *UnitPtr)
{
  int UnitNo,relUnitNo;
  int i;

  UnitNo=GET_UNIT_NO(UnitPtr);

  relUnitNo=((IS_HIDDEN_UNIT(UnitPtr)) ? REL_HIDDEN_NO(UnitNo) : UnitNo);

  switch (cc_modification){  /* no break required */
    case(CC_SDCC)      : return((IS_INPUT_UNIT(UnitPtr))||
                           (SpecialUnitNo >= cc_MaxSpecialUnitNo/2)||
                           (CC_LAYER_NO(UnitPtr)<NoOfLayers));
    case(CC_ECC) :
                       return ((IS_INPUT_UNIT(UnitPtr)) ||
                           ((float)relUnitNo/(float)(1+NoOfHiddenUnits)) <= CCC_M);
    case(CC_STAT) :
                       return ((IS_INPUT_UNIT(UnitPtr)) ||
                           (relUnitNo <= NoOfHiddenUnits + 1 -
                           (ccm_CurrentLayerHeight-ccm_MissingUnitsInLayer)));
    case(CC_LFCC) :
                       for(i=0;i<CCR_NO_OF_LINKS;i++){
                           if (UnitNo==ccr_ListOfChosenUnits[i]){
                                 return (TRUE);
                           }
                       }
                       return (FALSE); /* Nicht in Liste vorhanden */        
    case(CC_RLCC)      :
                       return(CC_LAYER_NO(UnitPtr) < cco_ActualLayer);
    default          : return (TRUE);  /* no modification */
  }
}
Ejemplo n.º 2
0
/* synchronous propagation (1 cycle) i.e. each unit puts its output onto
   its outgoing links and calculates its new activation.
*/
void  krart_prop_synch (void)
{
  struct Unit    *unit_ptr;

  /* calculate new activations of non input units
  */

  FOR_ALL_UNITS (unit_ptr) {

     if (!IS_INPUT_UNIT(unit_ptr)) {
        unit_ptr->act = (*unit_ptr->act_func) (unit_ptr);
     } /*if*/

  } /*FOR_ALL_UNITS*/

  /* set new output values
  */

  FOR_ALL_UNITS (unit_ptr) {

     if (unit_ptr->out_func == OUT_IDENTITY) {
        unit_ptr->Out.output = unit_ptr->act;
     } else {
        unit_ptr->Out.output = (*unit_ptr->out_func) (unit_ptr->act);
     } /*if*/

  } /*FOR_ALL_UNITS*/

} /* krart_prop_synch */
Ejemplo n.º 3
0
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
void  krart_save_inp_pat (TopoPtrArray topo_inp_ptr)
{
  TopoPtrArray   topo_ptr = topo_inp_ptr;

  while (*topo_ptr != NULL) {
     if (IS_INPUT_UNIT (*topo_ptr)) {
        (*topo_ptr)->value_a = (*topo_ptr)->act;
     } /*if*/
     topo_ptr++;
  } /*while*/
  return;
} /* krart_save_inp_pat () */
Ejemplo n.º 4
0
krui_err SnnsCLib::cc_calculateConnections(int SpecUnitNo)
{
  struct Unit * UnitPtr;
  int *ListOfAllUnits;
  int  cnt=0,i,j,Choose; 
  int FoundUnits=0;
 
  switch(cc_modification){
     case (CC_LFCC) :
        CALLOC_ERRORCHECK(ListOfAllUnits,NoOfInputUnits+NoOfHiddenUnits,int);
        FOR_ALL_UNITS(UnitPtr){
           if (IS_INPUT_UNIT(UnitPtr)||
              IS_HIDDEN_UNIT(UnitPtr)){
                ListOfAllUnits[FoundUnits++] = GET_UNIT_NO(UnitPtr);
           }     /* Copz numbers of every unit to LOAL */
        }

        if (FoundUnits<=CCR_NO_OF_LINKS){
           for(i=0;i<FoundUnits;i++){
              ccr_ListOfChosenUnits[i]=ListOfAllUnits[i];
           }     /* get input from all units */
        }
        else{
           for(i=0;i<CCR_NO_OF_LINKS;i++){
              Choose = (int)(u_drand48()*(float)(FoundUnits-i));    
                /* choose one of the remaining units */
              for (j=0,cnt=0;
                  ((cnt<Choose)||(ListOfAllUnits[j] == FIELD_EMPTY));
                   j++){
                 if (ListOfAllUnits[j] != FIELD_EMPTY) cnt++;
		 /* Count `til choosen number. There have to be 
                    CCR_NO_OF_LINKS entries remaining.*/
      	      }
              ccr_ListOfChosenUnits[i] = ListOfAllUnits[j];
              ListOfAllUnits[j] = FIELD_EMPTY;
              UnitPtr=kr_getUnitPtr(ccr_ListOfChosenUnits[i]);
                /* get Unit number and free place. */
           }
        }  
        free(ListOfAllUnits);
        return(KRERR_NO_ERROR);
     case(CC_RLCC) :
        if (cc_MaxSpecialUnitNo==1)
           cco_ActualLayer = NoOfLayers+1;
        else
          cco_ActualLayer = 1+(int)((SpecUnitNo*(NoOfLayers+0.9999)) / (cc_MaxSpecialUnitNo-1));
        return(KRERR_NO_ERROR);
     default : return(KRERR_NO_ERROR);
   }
}
Ejemplo n.º 5
0
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
bool  krart_inp_pat_changed (TopoPtrArray topo_inp_ptr)
{

   TopoPtrArray    topo_ptr = topo_inp_ptr;

   while (*topo_ptr != NULL) {
      if ((IS_INPUT_UNIT(*topo_ptr)) && ((*topo_ptr)->value_a != (*topo_ptr)->act)) {
         return (TRUE);
      } /*if*/
      topo_ptr++;
   } /*FOR_ALL_UNITS*/

   return (FALSE);
} /* krart_inp_pat_changed () */
Ejemplo n.º 6
0
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
int  krart_get_NoOfInputUnits (void)
{
   register struct Unit  *unit_ptr;
   int                   count           = 0;


   FOR_ALL_UNITS (unit_ptr) {

      if (IS_INPUT_UNIT(unit_ptr)) {
         count++;
      } /*if*/

   } /*FOR_ALL_UNITS*/

   return (count);


} /* krart_get_NoOfInputUnits () */
Ejemplo n.º 7
0
krui_err krart_reset_activations (void)
{
   krui_err        ret_code = KRERR_NO_ERROR;

   struct Unit     *unit_ptr;


   FOR_ALL_UNITS (unit_ptr) {

      if (! IS_INPUT_UNIT (unit_ptr)) {
         unit_ptr->act = unit_ptr->i_act;
      } /*if*/

      /* The output is set for input units, too
      */
      unit_ptr->Out.output = unit_ptr->act;

   } /*FOR_ALL_UNITS*/

   return (ret_code);

} /* krart_reset_activations () */