⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 art_ext.c

📁 自适应共振神经网络可以实现自动学习与分类具有自适应的功能
💻 C
📖 第 1 页 / 共 5 页
字号:
/*          0         - When successful:                                     */
/*          1         - Network not initialized or NULL                      */
/*          2         - ARTMAP component given for ART net type              */
/*          3         - ART component given for ARTMAP net type              */
/*          4         - Invalid component name given                         */
/* ------------------------------------------------------------------------- */
int VBPREFIX  GetArtVigil(netPTR net, int component, float *vigil) {
  
  if ((net==NULL)||(net->initB!=TRUE))
    return 1;

  /* Check network type and set */
  if (component==ARTA) {
    if (net->type!=ARTMAP)
      return 2;
    *vigil = net->map.base_vigil;
    return 0;
  }
  else if (component==ARTB) {
    if ((net->type!=ARTMAP)||(net->map.artB.type==NONE))
      return 2;
    *vigil = net->map.artB.vigil;
    return 0;
  }
  else if (component==ART) {
    if (net->type!=ART)
      return 3;
    *vigil = net->art.vigil;
    return 0;
  }
  else
    return 4;
}



/* ------------------------------------------------------------------------- */
/* GetArtWinner                                                              */
/*              Given a pointer to a network and an Art component returns    */
/*              the most recent winning category of the Art component.       */
/*                                                                           */
/* Arguments:                                                                */
/*          net       - A pointer to an initialized netowrk of type netTYPE  */
/*          component - ARTA, ARTB, or ART                                   */
/*                                                                           */
/* Return Values:                                                            */
/*       winner - When successful                                            */
/*           -1 - When no category met the vigilence level (no winner)       */
/*           -2 - When network type incompatible, net uninitialized or NULL  */
/* ------------------------------------------------------------------------- */
int VBPREFIX  GetArtWinner(netPTR net, int component) {
  
  if ((net==NULL)||(net->initB!=TRUE))
    return -2;

  /* Check network type and set */
  if (component==ARTA) {
    if (net->type!=ARTMAP)
      return -2;
    return net->map.artA.win_cat;
  }
  else if (component==ARTB) {
    if ((net->type!=ARTMAP)||(net->map.artB.type==NONE))
      return -2;
    return net->map.artB.win_cat;
  }
  else if (component==ART) {
    if (net->type!=ART)
      return -2;
    return net->art.win_cat;

  }
  else
    return -2;
}



/* ------------------------------------------------------------------------- */
/* GetArtBeta                                                                */
/*              Given a pointer to a network, a network component, and a     */
/*              pointer to a float, sets the float pointer value to the      */
/*              current recoding rate of the component.                      */
/*                                                                           */
/* Arguments:                                                                */
/*          net       - A pointer to an initialized netowrk of type netTYPE  */
/*          component - ART, ARTA, or ARTB                                   */
/*          beta      - A pointer to a float                                 */
/*                                                                           */
/* Return Values:                                                            */
/*	   0 - When successful                                               */
/*         1 - Network not initialized or NULL                               */
/*         2 - Incomptible component and type given                          */
/*         3 - Invalid component type given                                  */
/* ------------------------------------------------------------------------- */
int VBPREFIX  GetArtBeta(netPTR net, int component, float *beta) {

  if ((net==NULL)||(net->initB!=TRUE))
    return 1;

  /* Check network type and set */
  if (component==ARTA) {
    if (net->type!=ARTMAP)
      return 2;
    *beta = net->map.artA.beta;
    return 0;
  }
  else if (component==ARTB) {
    if ((net->type!=ARTMAP)||(net->map.artB.type==NONE))
      return 2;
    *beta = net->map.artB.beta;
    return 0;
  }
  else if (component==ART) {
    if (net->type!=ART)
      return 2;
    *beta = net->art.beta;
    return 0;
  }
  else
    return 3;
}



/* ------------------------------------------------------------------------- */
/* GetMap                                                                    */
/*              Given a pointer to a network of type ARTMAP, and a pointer   */
/*              to a list of floats, set the values in the list to the       */
/*              current mapfield activations.                                */
/*                                                                           */
/* Arguments:                                                                */
/*          net       - A pointer to an initialized network of type netTYPE  */
/*          list      - A pointer to a list of floats of size GetMapSize     */
/*                                                                           */
/* Return Values:                                                            */
/*          0 - When successful:                                             */
/*          1 - Network not initialized of NULL                              */
/*          2 - Network not of type ARTMAP                                   */
/* ------------------------------------------------------------------------- */
int VBPREFIX GetMap(netPTR net, float *list) {
  int i;
  FILE *dumpfile;
  
  if ((net==NULL)||(net->initB!=TRUE))
    return 1;

  /* Check network type and set */
  if (net->type!=ARTMAP)
    return 2;
  else {
    for (i=0;i<net->map.artB.nodes_used;i++)
      *(list+i)=(*(net->map.map+i));
    return 0;
  }
}
     

/* ------------------------------------------------------------------------- */
/* GetMapSize                                                                */
/*              Given a pointer to a network of type ARTMAP, returns the     */
/*              current number of mapfield nodes.                            */
/*                                                                           */
/* Arguments:                                                                */
/*          net       - A pointer to an initialized network of type netTYPE  */
/*                                                                           */
/* Return Values:                                                            */
/*     When successful:                                                      */
/*             The number of MapField Nodes                                  */
/*     When network is not of type ARTMAP, uninitialized or NULL             */
/*             -1                                                            */
/* ------------------------------------------------------------------------- */
int VBPREFIX  GetMapSize(netPTR net) {

  if ((net==NULL)||(net->initB!=TRUE))
    return -1;

  /* Check network type and set */
  if (net->type!=ARTMAP)
    return -1;
  else
    return net->map.artB.nodes_used;
}


/* ------------------------------------------------------------------------- */
/* GetArtSize                                                                */
/*              Given a pointer to a network, and a component type, returns  */
/*              current size of the art component.                           */
/*                                                                           */
/* Arguments:                                                                */
/*          net       - A pointer to an initialized netowrk of type netTYPE  */
/*          component - ART, ARTA, or ARTB                                   */
/*                                                                           */
/* Return Values:                                                            */
/*     When successful:                                                      */
/*             Size of Art Component                                         */
/*     When network type incompatible, network uninitialized or NULL         */
/*             -1                                                            */
/* ------------------------------------------------------------------------- */
int VBPREFIX  GetArtSize(netPTR net, int component) {
  int i;

  if ((net==NULL)||(net->initB!=TRUE))
    return -1;

  /* Check network type and set */
  if (component==ARTA) {
    if (net->type!=ARTMAP)
      return -1;
    else
      return net->map.artA.nodes_used;
  }
  else if (component==ARTB) {
    if (net->type!=ARTMAP)
      return -1;
    else
      return net->map.artB.nodes_used;
  }
  else if (component==ART) {
    if (net->type!=ART)
        return -1;
    else
      return net->art.nodes_used;
  }
  else
    return -1;
}



/* ------------------------------------------------------------------------- */
/* GetSetInput                                                               */
/*              Given a pointer to a pattern set, a pattern number, and a    */
/*              pointer to a list of floats of size GetSetInSize, sets the   */
/*              values of the list to the inputs of the given pattern.       */
/*                                                                           */
/* Arguments:                                                                */
/*     set         - A pointer to a set of patterns of type setTYPE          */
/*     pat_num     - A pattern number (integer)                              */
/*     list        - A pointer to a list of floats of size GetSetInSize      */
/*                                                                           */
/* Return Values:                                                            */
/*     0 - When successful:                                                  */
/*     1 - Set not initialized or NULL                                       */
/*     2 - Pattern number out of bounds                                      */
/* ------------------------------------------------------------------------- */
int VBPREFIX  GetSetInput(setPTR set, int pat_num, float *list) {
  int i;

  if ((set==NULL)||(set->initB!=TRUE))
    return 1;
  else if ((pat_num<0)||(pat_num > set->num_patterns))
    return 2;
  else {
   for (i=0;i<set->num_inputs;i++)
	list[i]=set->pattern[pat_num].input[i];
   return 0;
   }
}


/* ------------------------------------------------------------------------- */
/* GetSetInSize                                                              */
/*              Given a pointer to a pattern set, returns the size of the    */
/*              inputs patterns of the set.                                  */
/*                                                                           */
/* Arguments:                                                                */
/*     set         - A pointer to a set of patterns of type setTYPE          */
/*                                                                           */
/* Retrun Values:                                                            */
/*     When successful:                                                      */
/*             The number of inputs                                          */
/*     When set has not been initialized or NULL                             */
/*             -1                                                            */
/* ------------------------------------------------------------------------- */
int VBPREFIX  GetSetInSize(setPTR set) {

  if ((set==NULL)||(set->initB!=TRUE))
    return -1;
  else
    return set->num_inputs; 
}



/* ------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -