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

📄 lvqt.c

📁 LVQ - Learning Vector Quantization Demonstration Download xlvq Linux executable (128 kb) wlvq.ex
💻 C
📖 第 1 页 / 共 3 页
字号:
  fprintf(stderr, "\n");        /* terminate startup message */  printf("list of initialization modes (option -i#):\n");  printf("(choice of initial positions of the reference vectors,\n");  printf("a random offset can be added with the option -o#)\n");  printf("  name       initialization mode\n");  for (i = 0; initab[i].name; i++) /* list of initialization modes */    printf("  %-9s  %s\n", initab[i].name, initab[i].desc);  printf("list of activation normalization modes (option -j#)\n");  printf("  name       activation normalization mode\n");  for (i = 0; nrmtab[i].name; i++) /* list of normalization modes */    printf("  %-9s  %s\n", nrmtab[i].name, nrmtab[i].desc);  printf("list of variance/radius update methods (option -a#)\n");  printf("  name       variance update method\n");  for (i = 0; updtab[i].name; i++) /* list of update methods */    printf("  %-9s  %s\n", updtab[i].name, updtab[i].desc);  exit(0);                      /* abort the program */}  /* help() *//*--------------------------------------------------------------------*/static int code (const MODEINFO *tab, const char *name){                               /* --- get measure code */  for ( ; tab->name; tab++)     /* look up name in table */    if (strcmp(tab->name, name) == 0)      return tab->code;         /* return the code of the init. mode */  return -1;                    /* or an error indicator */}  /* code() *//*--------------------------------------------------------------------*/int main (int argc, char *argv[]){                               /* --- main function */  int    i, k = 0;              /* loop variables, buffers */  char   *s;                    /* to traverse options */  char   **optarg = NULL;       /* option argument */  #ifdef MATVERSION  char   *fn_in   = NULL;       /* name of input file */  #else  char   *fn_dom  = NULL;       /* name of domain/input vector file */  char   *fn_hdr  = NULL;       /* name of table header file */  #endif  char   *fn_pat  = NULL;       /* name of table file */  char   *fn_out  = NULL;       /* name of output file */  char   *blanks  = NULL;       /* blanks */  char   *fldseps = NULL;       /* field  separators */  char   *recseps = NULL;       /* record separators */  char   *nrmname = "hard";     /* name of normalization mode */  char   *ininame = "uniform";  /* name of initialization mode */  char   *updname = "dist";     /* name of variance update method */  int    veccnt   = 2;          /* number of reference vectors */  int    type     = LVQ_CENTER; /* prototype type */  int    gauss    = 0;          /* flag for Gaussian m.s. function */  double params[] = {2, 0};     /* distribution function parameters */  int    nmode    = 0;          /* normalization mode */  double wtarf    = 0;          /* winner takes all radius factor */  int    owrite   = 0;          /* overwrite parameters with options */  int    imode    = 0;          /* initialization mode */  double range    = 0;          /* range for random offsets */  int    method   = 0;          /* variance update method */  double exp      =  0.0;       /* neuron activation exponent */  double lrate    =  0.01;      /* initial learning rate */  double decay    = -0.1;       /* learning rate decay parameter */  double radius   =  1;         /* initial radius/std. deviation */  double scale    =  1;         /* prototype size scaling factor */  int    seed     = (int)time(NULL); /* seed value for random numbers */  int    update   = 1, u;       /* number of patterns between updates */  int    epochs   = 1000;       /* number of update epochs */  double trmchg   = 0;          /* maximum change for termination */  int    norm     = 1;          /* flag for pattern normalization */  int    shuffle  = 1;          /* shuffle pattern set */  int    dmode    = LVQ_TITLE;  /* description mode */  int    maxlen   = 0;          /* maximal output line length */  #ifdef MATVERSION  int    patcnt   = 0;          /* number of patterns */  int    valcnt   = 0;          /* number of values per pattern */  TFSERR *err;                  /* error information */  #else  int    flags    = AS_NOXATT|AS_NOUNKS;  /* table file read flags */  TUPLE  *tpl;                  /* to traverse the data tuples */  #endif  double chg, max;              /* (max.) change of a center coord. */  prgname = argv[0];            /* get program name for error msgs. */  /* --- print startup/usage message --- */  if (argc > 1) {               /* if arguments are given */    fprintf(stderr, "%s - %s\n", argv[0], DESCRIPTION);    fprintf(stderr, VERSION); } /* print a startup message */  else {                        /* if no argument given */    #ifdef MATVERSION    printf("usage: %s [options] patfile outfile [infile]\n", argv[0]);    #else    printf("usage: %s [options] domfile "                    "[-d|-h hdrfile] tabfile outfile\n", argv[0]);    #endif    printf("%s\n", DESCRIPTION);    printf("%s\n", VERSION);    printf("-c#      number of reference vectors "                    "(default: %d)\n", veccnt);    printf("-Z#      use prototype size "                    "(initial radius, default: %g)\n", radius);    printf("-G       Gaussian activation function "                    "(default: Cauchy function)\n");    printf("-p#:#    activation function parameters  "                    "(default: %g:%g)\n", params[0], params[1]);    printf("-j#      activation normalization mode   "                    "(default: %s)\n", nrmname);    printf("-y#      winner takes all radius factor  "                    "(default: %g)\n", wtarf);    printf("-P       overwrite parameters read "                    "with command line options\n");    printf("-i#      initialization mode             "                    "(default: %s)\n", ininame);    printf("-o#      random offset range             "                    "(default: %g)\n", range);    printf("-x#      exponent for neuron activations "                    "(default: %g)\n", exp);    printf("-X#      prototype size scaling factor   "                    "(default: %g)\n", scale);    printf("-z       replace old size with new size  "                    "(default: use learning rate)\n");    printf("-t#:#    initial learning rate and decay "                    "(default: %g:%g)\n", lrate, decay);    printf("-e#      maximum number of update epochs "                    "(default: %d)\n", epochs);    printf("-T#      maximum change for termination  "                    "(default: %g)\n", trmchg);    printf("-k#      patterns between two weight updates "                    "(default: %d)\n", update);    printf("-a#      variance/radius update method "                    "(default: %s)\n", updname);    printf("-!       print a list of init. and norm. modes "                    "and update methods\n");    printf("-q       do not normalize the input value ranges\n");    printf("-s       do not shuffle patterns between epochs\n");    printf("-S#      seed value for random number generator "                    "(default: time)\n");    printf("-l#      output line length (default: no limit)\n");    printf("-b/f/r#  blank characters, field and record separators\n"           "         (default: \" \\t\\r\", \" \\t\", \"\\n\")\n");    #ifdef MATVERSION    printf("patfile  pattern file to read (no header, only numbers)\n");    printf("outfile  file to write reference vectors to\n");    printf("infile   file to read  reference vectors from "                    "(optional)\n");    #else    printf("-n       number of tuple occurrences in last field\n");    printf("domfile  file containing domain descriptions\n"           "         (and maybe a set of reference vectors)\n");    printf("-d       use default header "                    "(field names = field numbers)\n");    printf("-h       read table header (field names) from hdrfile\n");    printf("hdrfile  file containing table header (field names)\n");    printf("tabfile  table file to read "                    "(field names in first record)\n");    printf("outfile  file to write reference vectors to\n");    #endif    return 0;                   /* print a usage message */  }                             /* and abort the program */  /* --- evaluate arguments --- */  for (i = 1; i < argc; i++) {  /* traverse arguments */    s = argv[i];                /* get option argument */    if (optarg) { *optarg = s; optarg = NULL; continue; }    if ((*s == '-') && *++s) {  /* -- if argument is an option */      while (1) {               /* traverse characters */        switch (*s++) {         /* evaluate option */          case '!': help();                                     break;          case 'c': veccnt  = (int)strtol(s, &s, 0);            break;          case 'i': optarg  = &ininame;                         break;          case 'o': range   =      strtod(s, &s);               break;          case 'G': gauss   = 1;                                break;          case 'Z': type   |= LVQ_SIZE; radius = strtod(s, &s); break;          case 'p': getdblvec(s, &s, 2, params);                break;          case 'j': optarg  = &nrmname;                         break;          case 'y': wtarf   =      strtod(s, &s);               break;          case 'P': owrite  = 1;                                break;          case 'x': exp     =      strtod(s, &s);               break;          case 'X': scale   =      strtod(s, &s);               break;          case 'z': method |= LVQ_REPLACE;                      break;          case 't': getdbls(s, &s, 2, &lrate, &decay);          break;          case 'l': maxlen  = (int)strtol(s, &s, 0);            break;          case 'e': epochs  = (int)strtol(s, &s, 0);            break;          case 'T': trmchg  =      strtod(s, &s);               break;          case 'k': update  = (int)strtol(s, &s, 0);            break;          case 'a': optarg  = &updname;                         break;          case 'q': norm    = 0;                                break;          case 's': shuffle = 0;                                break;          case 'S': seed    = (int)strtol(s, &s, 0);            break;          case 'b': optarg  = &blanks;                          break;          case 'f': optarg  = &fldseps;                         break;          case 'r': optarg  = &recseps;                         break;          #ifndef MATVERSION          case 'n': flags  |= AS_WEIGHT;                        break;          case 'd': flags  |= AS_DFLT;                          break;          case 'h': optarg  = &fn_hdr;                          break;          #endif          default : error(E_OPTION, *--s);                      break;        }                       /* set option variables */        if (!*s) break;         /* if at end of string, abort loop */        if (optarg) { *optarg = s; optarg = NULL; break; }      } }                       /* get option argument */    else {                      /* -- if argument is no option */      switch (k++) {            /* evaluate non-option */        #ifdef MATVERSION        case  0: fn_pat = s;      break;        case  1: fn_out = s;      break;        case  2: fn_in  = s;      break;        #else        case  0: fn_dom = s;      break;        case  1: fn_pat = s;      break;        case  2: fn_out = s;      break;        #endif        default: error(E_ARGCNT); break;      }                         /* note filenames */    }  }  if (optarg) error(E_OPTARG);  /* check the option argument */  #ifdef MATVERSION  if ((k != 2) && (k != 3))     /* check the number */

⌨️ 快捷键说明

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