int main() { double w[INPUTNO+1] ;/*重みとしきい値*/ double e[MAXINPUTNO][INPUTNO] ;/*データセット*/ double o ;/*出力*/ int i,j ;/*繰り返しの制御*/ int n_of_e ;/*データの個数*/ /*重みの初期化*/ initw(w) ; /*入力データの読み込み*/ n_of_e=getdata(e) ; printf("データの個数:%d\n",n_of_e) ; /*計算の本体*/ for(i=0;i<n_of_e;++i){ printf("%d ",i) ; for(j=0;j<INPUTNO;++j) printf("%lf ",e[i][j]) ; o=forward(w,e[i]) ; printf("%lf\n",o) ; } return 0 ; }
bool_t initw_1_svc(void *argp, int *result, struct svc_req *rqstp) { *result = initw (); return 1; }
bool_t initw_1_svc(void *w,int *ptr_retcode,struct svc_req *rqstp) { printf("Calling initw()\n"); *ptr_retcode=initw(); printf("Ccompleted initw()\n"); return(TRUE); }
/*------------------------------------------------------------------------ * main - insert, delete, or look up words in a dictionary as specified *------------------------------------------------------------------------ */ int main(int argc, char *argv[]) { char word[MAXWORD+1]; /* space to hold word from input line */ char cmd; int wrdlen; /* length of input word */ /* set up connection for remote procedure call */ handle = clnt_create(RMACHINE, RDICTPROG, RDICTVERS, "tcp"); if (handle == 0) { printf("Could not contact remote program.\n"); exit(1); } while (1) { wrdlen = nextin(&cmd, word); if (wrdlen < 0) exit(0); word[wrdlen] = '\0'; switch (cmd) { case 'I': /* "initialize" */ initw(); printf("Dictionary initialized to empty.\n"); break; case 'i': /* "insert" */ insertw(word); printf("%s inserted.\n",word); break; case 'd': /* "delete" */ if (deletew(word)) printf("%s deleted.\n",word); else printf("%s not found.\n",word); break; case 'l': /* "lookup" */ if (lookupw(word)) printf("%s was found.\n",word); else printf("%s was not found.\n",word); break; case 'q': /* quit */ printf("program quits.\n"); exit(0); default: /* illegal input */ printf("command %c invalid.\n", cmd); break; } } }
int main(int argc, char ** argv) { bool shuffle = false; vector<vector<int> > trainx, testx; vector<int> trainy, testy; load(trainx, trainy, "a1a.train"); load(testx, testy, "a1a.test"); //experiment parameters float mu[]= {0.0, 0.5, 1.0, 3.0, 5.0}; float r[]= {0.1, 0.2, 0.5, 0.75, 1.0}; for(int i=0; i < sizeof(mu) / sizeof(float); i++) { for(int j=0; j < sizeof(r) / sizeof(float); j++) { if(i==0) cout << "Perceptron (mu = 0), r = " << r[j] << endl; else cout << "Margin Perceptron, mu = " << mu[i] << ", r = "<< r[j] << endl; //initialize w, b using random values between -1 to 1 float w[d]; initw(w); float b; initb(b); //training cout << "3 epochs" <<endl; train(trainx, trainy, w, b, mu[i], r[j], 3, shuffle, false); test(testx, testy, w, b, mu[i]); cout << "5 epochs" <<endl; train(trainx, trainy, w, b, mu[i], r[j], 5, shuffle, false); test(testx, testy, w, b, mu[i]); } } return 0; }
main() { initw(adj,"-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1"); for (;;) { clear(); setup(); if (!pop) break; adjust(); display(); while (pop) { adjust(); dogen(); display(); if (kbhit()) {getchar(); break;} if (doneflag) break; } } }
/*------------------------------------------------------------------------ * main - insert, delete, or look up words in a dictionary as specified *------------------------------------------------------------------------ */ int main(int argc, char argv[]) { char word[MAXWORD+1]; /* space to hold word from input line */ char cmd; int wrdlen; /* length of input word */ while (1) { wrdlen = nextin(&cmd, word); if (wrdlen < 0) exit(0); word[wrdlen] = '\0'; switch (cmd) { case 'I': /* "initialize" */ initw(); printf("Dictionary initialized to empty.\n"); break; case 'i': /* "insert" */ insertw(word); printf("%s inserted.\n",word); break; case 'd': /* "delete" */ if (deletew(word)) printf("%s deleted.\n",word); else printf("%s not found.\n",word); break; case 'l': /* "lookup" */ if (lookupw(word)) printf("%s was found.\n",word); else printf("%s was not found.\n",word); break; case 'q': /* quit */ printf("program quits.\n"); exit(0); default: /* illegal input */ printf("command %c invalid.\n", cmd); break; } } }
// Canvas functions Canvas::Canvas( int width, int height, const char * windowTitle ) { // initialize openGL and everything glutWin initw( height, width, 20, 20, GLUT_SINGLE | GLUT_RGB, windowTitle ); // make sure the frustum is set up properly setWindow( 0.0f, (float)width, 0.0f, (float)height ); setViewPort( 0, width, 0, height ); // set turtle position currPos = Point2( 0.0f, 0.0f ); currDir = 0.0f; // set initial colors setBackgroundColor( 0.0f, 0.0f, 0.0f ); setColor( 1.0f, 0.0f, 0.0f ); }
/*------------------------------------------------------------------------ * initw_1_svc - server side interface to remote procedure initw *------------------------------------------------------------------------ */ int * initw_1_svc(void *w, struct svc_req *rqstp) { retcode = initw(); return &retcode; }