void EATrain(int argc, char **argv) { const char *ee_file, *de_file, *dw_file, *entity_cnts_file, *word_cnts_file, *dst_doc_vecs_file, *dst_word_vecs_file, *dst_entity_vecs_file; bool share_doc_vec = 1; int doc_vec_dim = GetIntArgValue(argc, argv, "-d", 100); int num_rounds = GetIntArgValue(argc, argv, "-r", 10); int num_threads = GetIntArgValue(argc, argv, "-t", 2); int num_negative_samples = GetIntArgValue(argc, argv, "-n", 10); float starting_alpha = GetFloatArgValue(argc, argv, "-sa", 0.06f); float min_alpha = GetFloatArgValue(argc, argv, "-ma", 0.0001f); ee_file = GetArgValue(argc, argv, "-ee"); de_file = GetArgValue(argc, argv, "-de"); dw_file = GetArgValue(argc, argv, "-dw"); entity_cnts_file = GetArgValue(argc, argv, "-ecnt"); word_cnts_file = GetArgValue(argc, argv, "-wcnt"); dst_doc_vecs_file = GetArgValue(argc, argv, "-docvec"); dst_word_vecs_file = GetArgValue(argc, argv, "-wordvec"); dst_entity_vecs_file = GetArgValue(argc, argv, "-entityvec"); if (!ee_file) { DataSet data_set = DataSet::WIN_20NG; configFiles(data_set, ee_file, de_file, dw_file, entity_cnts_file, word_cnts_file, dst_doc_vecs_file, dst_word_vecs_file, dst_entity_vecs_file); } //if (argc >= 7) //{ // doc_vec_dim = atoi(argv[1]); // num_rounds = atoi(argv[2]); // num_threads = atoi(argv[3]); // num_negative_samples = atoi(argv[4]); // starting_alpha = (float)atof(argv[5]); // min_alpha = (float)atof(argv[6]); // if (argc == 8) // dst_doc_vecs_file = argv[7]; //} //else //{ // DataSet data_set = DataSet::WIN_20NG; // configFiles(data_set, ee_file, de_file, dw_file, entity_cnts_file, word_cnts_file, // dst_doc_vecs_file, dst_word_vecs_file, dst_entity_vecs_file); //} printf("ee_file: %s\nde_file: %s\ndw_file: %s\n", ee_file, de_file, dw_file); printf("vec_dim: %d\nnum_rounds: %d\nnum_threads: %d\nnum_neg_samples: %d\nstarting_alpha: %f\nmin_alpha: %f\n", doc_vec_dim, num_rounds, num_threads, num_negative_samples, starting_alpha, min_alpha); EADocVecTrainer eatrain(num_rounds, num_threads, num_negative_samples, starting_alpha, min_alpha); eatrain.AllJointThreaded(ee_file, de_file, dw_file, entity_cnts_file, word_cnts_file, doc_vec_dim, share_doc_vec, dst_doc_vecs_file, dst_word_vecs_file, dst_entity_vecs_file); }
float GetFloatArgValue(int argc, char **argv, const char *arg, float def_val) { char *arg_val = GetArgValue(argc, argv, arg); if (arg_val) return atof(arg_val); return def_val; }
int GetIntArgValue(int argc, char **argv, const char *arg, int def_val) { char *arg_val = GetArgValue(argc, argv, arg); if (arg_val) return atoi(arg_val); return def_val; }
void InitEngineUCI( const char * iniDir, ChessProgramState * cps ) { // replace engine command line by adapter command with expanded meta-symbols if( cps->isUCI ) { char *p, *q; char polyglotCommand[MSG_SIZ]; p = appData.adapterCommand; q = polyglotCommand; while(*p) { if(*p == '\\') p++; else if(*p == '%') { // substitute marker char argName[MSG_SIZ], buf[MSG_SIZ], *s = buf; if(*++p == '%') { // second %, expand as f or s in option name (e.g. %%cp -> fcp) *s++ = cps == &first ? 'f' : 's'; p++; } while(*p >= '0' && *p) *s++ = *p++; // copy option name *s = NULLCHAR; if(cps == &second) { // change options for first into those for second engine if(strstr(buf, "first") == buf) sprintf(argName, "second%s", buf+5); else if(buf[0] == 'f') sprintf(argName, "s%s", buf+1); else safeStrCpy(argName, buf, sizeof(argName)/sizeof(argName[0])); } else safeStrCpy(argName, buf, sizeof(argName)/sizeof(argName[0])); if(GetArgValue(argName)) { // look up value of option with this name s = argName; while(*s) *q++ = *s++; } else DisplayFatalError("Bad adapter command", 0, 1); continue; } if(*p) *q++ = *p++; } *q = NULLCHAR; cps->program = StrSave(polyglotCommand); cps->dir = appData.polyglotDir; } }