#include #include #include #include float vectors_dot_prod(const float *x, const float *y, int n) { float res = 0.0; int i; for (i = 0; i < n; i++) { res += x[i] * y[i]; } return res; } float** Make2DFloatArray(int arraySizeX, int arraySizeY) { float** theArray; theArray = (float**) malloc(arraySizeX*sizeof(float*)); for (int i = 0; i < arraySizeX; i++) theArray[i] = (float*) malloc(arraySizeY*sizeof(float)); return theArray; } float calc_sigmoid(float x) { return (1 / (1 + expf(-x))); } float sigmoid_deriv(float x) { float sigmoid_computed = calc_sigmoid(x); return sigmoid_computed * (1 - sigmoid_computed); } float* vector_matrix_prod(float **x, const float *y, int rows, int cols) { int col, row; float *result = (float *)malloc(cols * sizeof(float *)); float res; for (col = 0; col < cols; col++) { int column = col; res = 0.0; for (row = 0; row < rows; row++) { res += y[row] * x[row][column]; } result[column] = res; } return result; } void print_vector(float *x, int size) { printf("Vector is\n"); for (int i = 0; i < size; i++) { printf("%f\t", x[i]); } printf("\n\n"); } void print_matrix(float **x, int rows, int cols) { printf("Matrix is\n"); for (int row=0; row < rows; row++) { for (int col=0; col < cols; col++) { printf("%f\t", x[row][col]); } printf("\n"); } } float genRand() { float num = ((float)rand()/(float)(RAND_MAX/2)) - 1; return num; } float* create_starting_board() { float* input = (float *)malloc(26 * sizeof(float *)); float tmp_input[26] = {0, 2, 0, 0, 0, 0, -5, 0, -3, 0, 0, 0, 5, -5, 0, 0, 0, 3, 0, 5, 0, 0, 0, 0, -2, 0}; for (int i=0; i < 26; i++) { input[i] = tmp_input[i]; } return input; } float* create_1D_layer(int size) { float *input = (float *)malloc(size * sizeof(float *)); int i; for (i=0; i