void main() { int sz = 3; int eql = 0; int mov = 0; int **t = malloc(sz*(sizeof(int)+1)); for(i = 1; i <= sz; i++) t[i] = malloc(sz*sizeof(int)); int **b = malloc(sz*(sizeof(int)+1)); for(i = 1; i <= sz; i++) b[i] = malloc(sz*sizeof(int)); char roc; int n; initt(t, sz); initb(t, b, sz); while(eq(t, b, sz)) initb(t, b, sz); while(!eql) { printf("Target: \n"); printb(t, sz); printf("Board: \n"); printb(b, sz); printf("What to flip: "); scanf(" %c", &roc); scanf(" %d", &n); switch(roc) { case 'r': fliprow(b, sz, n); break; case 'c': flipcol(b, sz, n); break; default: perror("Please specify r or c and an number"); break; } printf("Moves Taken: %d\n", ++mov); if(eq(t, b, sz)) { printf("You win!\n"); eql = 1; } } }
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; }
Buf *newb() { Buf *buf= calloc(1, sizeof *buf); initb(buf); return buf; }