├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── main.c ├── matrix ├── matrix.c ├── matrix.h ├── ops.c └── ops.h ├── neural ├── activations.c ├── activations.h ├── nn.c └── nn.h ├── testing_net ├── descriptor ├── hidden └── output └── util ├── img.c └── img.h /.gitignore: -------------------------------------------------------------------------------- 1 | data/ 2 | *.o 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Mark Kraay 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | C_SOURCES = $(wildcard matrix/*.c neural/*.c util/*.c *.c) 2 | HEADERS = $(wildcard matrix/*.h neural/*.h util/*.h *.h) 3 | OBJ = ${C_SOURCES:.c=.o} 4 | CFLAGS = 5 | 6 | MAIN = main 7 | CC = /usr/bin/gcc 8 | LINKER = /usr/bin/ld 9 | 10 | run: ${MAIN} 11 | ./${MAIN} 12 | 13 | main: ${OBJ} 14 | ${CC} ${CFLAGS} $^ -o $@ -lm 15 | 16 | # Generic rules 17 | %.o: %.c ${HEADERS} 18 | ${CC} ${CFLAGS} -c $< -o $@ -lm 19 | 20 | clean: 21 | rm matrix/*.o *.o neural/*.o util/*.o ${MAIN} 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mnist-from-scratch 2 | Code for training basic neural networks, especially the MNIST numbers dataset. 3 | 4 | ### Get the training dataset 5 | ``` 6 | kaggle datasets download -d oddrationale/mnist-in-csv 7 | unzip mnist-in-csv.zip -d data 8 | ``` 9 | 10 | ### Video 11 | [![Watch the video](https://img.youtube.com/vi/ReOxVMxS83o/maxresdefault.jpg)](https://youtu.be/ReOxVMxS83o) 12 | 13 | ### Checkout the other branches for different parallelization solutions! 14 | -------------------------------------------------------------------------------- /main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "util/img.h" 6 | #include "neural/activations.h" 7 | #include "neural/nn.h" 8 | #include "matrix/matrix.h" 9 | #include "matrix/ops.h" 10 | 11 | int main() { 12 | srand(time(NULL)); 13 | 14 | //TRAINING 15 | // int number_imgs = 10000; 16 | // Img** imgs = csv_to_imgs("./data/mnist_test.csv", number_imgs); 17 | // NeuralNetwork* net = network_create(784, 300, 10, 0.1); 18 | // network_train_batch_imgs(net, imgs, number_imgs); 19 | // network_save(net, "testing_net"); 20 | 21 | // PREDICTING 22 | // int number_imgs = 3000; 23 | // Img** imgs = csv_to_imgs("data/mnist_test.csv", number_imgs); 24 | // NeuralNetwork* net = network_load("testing_net"); 25 | // double score = network_predict_imgs(net, imgs, 1000); 26 | // printf("Score: %1.5f\n", score); 27 | 28 | // imgs_free(imgs, number_imgs); 29 | // network_free(net); 30 | return 0; 31 | } -------------------------------------------------------------------------------- /matrix/matrix.c: -------------------------------------------------------------------------------- 1 | #include "matrix.h" 2 | #include 3 | #include 4 | #include 5 | 6 | #define MAXCHAR 100 7 | 8 | Matrix* matrix_create(int row, int col) { 9 | Matrix *matrix = malloc(sizeof(Matrix)); 10 | matrix->rows = row; 11 | matrix->cols = col; 12 | matrix->entries = malloc(row * sizeof(double*)); 13 | for (int i = 0; i < row; i++) { 14 | matrix->entries[i] = malloc(col * sizeof(double)); 15 | } 16 | return matrix; 17 | } 18 | 19 | void matrix_fill(Matrix *m, int n) { 20 | for (int i = 0; i < m->rows; i++) { 21 | for (int j = 0; j < m->cols; j++) { 22 | m->entries[i][j] = n; 23 | } 24 | } 25 | } 26 | 27 | void matrix_free(Matrix *m) { 28 | for (int i = 0; i < m->rows; i++) { 29 | free(m->entries[i]); 30 | } 31 | free(m->entries); 32 | free(m); 33 | m = NULL; 34 | } 35 | 36 | void matrix_print(Matrix* m) { 37 | printf("Rows: %d Columns: %d\n", m->rows, m->cols); 38 | for (int i = 0; i < m->rows; i++) { 39 | for (int j = 0; j < m->cols; j++) { 40 | printf("%1.3f ", m->entries[i][j]); 41 | } 42 | printf("\n"); 43 | } 44 | } 45 | 46 | Matrix* matrix_copy(Matrix* m) { 47 | Matrix* mat = matrix_create(m->rows, m->cols); 48 | for (int i = 0; i < m->rows; i++) { 49 | for (int j = 0; j < m->cols; j++) { 50 | mat->entries[i][j] = m->entries[i][j]; 51 | } 52 | } 53 | return mat; 54 | } 55 | 56 | void matrix_save(Matrix* m, char* file_string) { 57 | FILE* file = fopen(file_string, "w"); 58 | fprintf(file, "%d\n", m->rows); 59 | fprintf(file, "%d\n", m->cols); 60 | for (int i = 0; i < m->rows; i++) { 61 | for (int j = 0; j < m->cols; j++) { 62 | fprintf(file, "%.6f\n", m->entries[i][j]); 63 | } 64 | } 65 | printf("Successfully saved matrix to %s\n", file_string); 66 | fclose(file); 67 | } 68 | 69 | Matrix* matrix_load(char* file_string) { 70 | FILE* file = fopen(file_string, "r"); 71 | char entry[MAXCHAR]; 72 | fgets(entry, MAXCHAR, file); 73 | int rows = atoi(entry); 74 | fgets(entry, MAXCHAR, file); 75 | int cols = atoi(entry); 76 | Matrix* m = matrix_create(rows, cols); 77 | for (int i = 0; i < m->rows; i++) { 78 | for (int j = 0; j < m->cols; j++) { 79 | fgets(entry, MAXCHAR, file); 80 | m->entries[i][j] = strtod(entry, NULL); 81 | } 82 | } 83 | printf("Sucessfully loaded matrix from %s\n", file_string); 84 | fclose(file); 85 | return m; 86 | } 87 | 88 | double uniform_distribution(double low, double high) { 89 | double difference = high - low; // The difference between the two 90 | int scale = 10000; 91 | int scaled_difference = (int)(difference * scale); 92 | return low + (1.0 * (rand() % scaled_difference) / scale); 93 | } 94 | 95 | void matrix_randomize(Matrix* m, int n) { 96 | // Pulling from a random distribution of 97 | // Min: -1 / sqrt(n) 98 | // Max: 1 / sqrt(n) 99 | double min = -1.0 / sqrt(n); 100 | double max = 1.0 / sqrt(n); 101 | for (int i = 0; i < m->rows; i++) { 102 | for (int j = 0; j < m->cols; j++) { 103 | m->entries[i][j] = uniform_distribution(min, max); 104 | } 105 | } 106 | } 107 | 108 | int matrix_argmax(Matrix* m) { 109 | // Expects a Mx1 matrix 110 | double max_score = 0; 111 | int max_idx = 0; 112 | for (int i = 0; i < m->rows; i++) { 113 | if (m->entries[i][0] > max_score) { 114 | max_score = m->entries[i][0]; 115 | max_idx = i; 116 | } 117 | } 118 | return max_idx; 119 | } 120 | 121 | Matrix* matrix_flatten(Matrix* m, int axis) { 122 | // Axis = 0 -> Column Vector, Axis = 1 -> Row Vector 123 | Matrix* mat; 124 | if (axis == 0) { 125 | mat = matrix_create(m->rows * m->cols, 1); 126 | } else if (axis == 1) { 127 | mat = matrix_create(1, m->rows * m->cols); 128 | } else { 129 | printf("Argument to matrix_flatten must be 0 or 1"); 130 | exit(EXIT_FAILURE); 131 | } 132 | for (int i = 0; i < m->rows; i++) { 133 | for (int j = 0; j < m->cols; j++) { 134 | if (axis == 0) mat->entries[i * m->cols + j][0] = m->entries[i][j]; 135 | else if (axis == 1) mat->entries[0][i * m->cols + j] = m->entries[i][j]; 136 | } 137 | } 138 | return mat; 139 | } -------------------------------------------------------------------------------- /matrix/matrix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct { 4 | double** entries; 5 | int rows; 6 | int cols; 7 | } Matrix; 8 | 9 | Matrix* matrix_create(int row, int col); 10 | void matrix_fill(Matrix *m, int n); 11 | void matrix_free(Matrix *m); 12 | void matrix_print(Matrix *m); 13 | Matrix* matrix_copy(Matrix *m); 14 | void matrix_save(Matrix* m, char* file_string); 15 | Matrix* matrix_load(char* file_string); 16 | void matrix_randomize(Matrix* m, int n); 17 | int matrix_argmax(Matrix* m); 18 | Matrix* matrix_flatten(Matrix* m, int axis); -------------------------------------------------------------------------------- /matrix/ops.c: -------------------------------------------------------------------------------- 1 | #include "ops.h" 2 | #include 3 | #include 4 | 5 | int check_dimensions(Matrix *m1, Matrix *m2) { 6 | if (m1->rows == m2->rows && m1->cols == m2->cols) return 1; 7 | return 0; 8 | } 9 | 10 | Matrix* multiply(Matrix *m1, Matrix *m2) { 11 | if (check_dimensions(m1, m2)) { 12 | Matrix *m = matrix_create(m1->rows, m1->cols); 13 | for (int i = 0; i < m1->rows; i++) { 14 | for (int j = 0; j < m2->cols; j++) { 15 | m->entries[i][j] = m1->entries[i][j] * m2->entries[i][j]; 16 | } 17 | } 18 | return m; 19 | } else { 20 | printf("Dimension mistmatch multiply: %dx%d %dx%d\n", m1->rows, m1->cols, m2->rows, m2->cols); 21 | exit(1); 22 | } 23 | } 24 | 25 | Matrix* add(Matrix *m1, Matrix *m2) { 26 | if (check_dimensions(m1, m2)) { 27 | Matrix *m = matrix_create(m1->rows, m1->cols); 28 | for (int i = 0; i < m1->rows; i++) { 29 | for (int j = 0; j < m2->cols; j++) { 30 | m->entries[i][j] = m1->entries[i][j] + m2->entries[i][j]; 31 | } 32 | } 33 | return m; 34 | } else { 35 | printf("Dimension mistmatch add: %dx%d %dx%d\n", m1->rows, m1->cols, m2->rows, m2->cols); 36 | exit(1); 37 | } 38 | } 39 | 40 | Matrix* subtract(Matrix *m1, Matrix *m2) { 41 | if (check_dimensions(m1, m2)) { 42 | Matrix *m = matrix_create(m1->rows, m1->cols); 43 | for (int i = 0; i < m1->rows; i++) { 44 | for (int j = 0; j < m2->cols; j++) { 45 | m->entries[i][j] = m1->entries[i][j] - m2->entries[i][j]; 46 | } 47 | } 48 | return m; 49 | } else { 50 | printf("Dimension mistmatch subtract: %dx%d %dx%d\n", m1->rows, m1->cols, m2->rows, m2->cols); 51 | exit(1); 52 | } 53 | } 54 | 55 | Matrix* apply(double (*func)(double), Matrix* m) { 56 | Matrix *mat = matrix_copy(m); 57 | for (int i = 0; i < m->rows; i++) { 58 | for (int j = 0; j < m->cols; j++) { 59 | mat->entries[i][j] = (*func)(m->entries[i][j]); 60 | } 61 | } 62 | return mat; 63 | } 64 | 65 | Matrix* dot(Matrix *m1, Matrix *m2) { 66 | if (m1->cols == m2->rows) { 67 | Matrix *m = matrix_create(m1->rows, m2->cols); 68 | for (int i = 0; i < m1->rows; i++) { 69 | for (int j = 0; j < m2->cols; j++) { 70 | double sum = 0; 71 | for (int k = 0; k < m2->rows; k++) { 72 | sum += m1->entries[i][k] * m2->entries[k][j]; 73 | } 74 | m->entries[i][j] = sum; 75 | } 76 | } 77 | return m; 78 | } else { 79 | printf("Dimension mistmatch dot: %dx%d %dx%d\n", m1->rows, m1->cols, m2->rows, m2->cols); 80 | exit(1); 81 | } 82 | } 83 | 84 | Matrix* scale(double n, Matrix* m) { 85 | Matrix* mat = matrix_copy(m); 86 | for (int i = 0; i < m->rows; i++) { 87 | for (int j = 0; j < m->cols; j++) { 88 | mat->entries[i][j] *= n; 89 | } 90 | } 91 | return mat; 92 | } 93 | 94 | Matrix* addScalar(double n, Matrix* m) { 95 | Matrix* mat = matrix_copy(m); 96 | for (int i = 0; i < m->rows; i++) { 97 | for (int j = 0; j < m->cols; j++) { 98 | mat->entries[i][j] += n; 99 | } 100 | } 101 | return mat; 102 | } 103 | 104 | Matrix* transpose(Matrix* m) { 105 | Matrix* mat = matrix_create(m->cols, m->rows); 106 | for (int i = 0; i < m->rows; i++) { 107 | for (int j = 0; j < m->cols; j++) { 108 | mat->entries[j][i] = m->entries[i][j]; 109 | } 110 | } 111 | return mat; 112 | } -------------------------------------------------------------------------------- /matrix/ops.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "matrix.h" 4 | 5 | Matrix* multiply(Matrix* m1, Matrix* m2); 6 | Matrix* add(Matrix* m1, Matrix* m2); 7 | Matrix* subtract(Matrix* m1, Matrix* m2); 8 | Matrix* dot(Matrix* m1, Matrix* m2); 9 | Matrix* apply(double (*func)(double), Matrix* m); 10 | Matrix* scale(double n, Matrix* m); 11 | Matrix* addScalar(double n, Matrix* m); 12 | Matrix* transpose(Matrix* m); 13 | -------------------------------------------------------------------------------- /neural/activations.c: -------------------------------------------------------------------------------- 1 | #include "activations.h" 2 | 3 | #include 4 | #include "../matrix/ops.h" 5 | 6 | double sigmoid(double input) { 7 | return 1.0 / (1 + exp(-1 * input)); 8 | } 9 | 10 | Matrix* sigmoidPrime(Matrix* m) { 11 | Matrix* ones = matrix_create(m->rows, m->cols); 12 | matrix_fill(ones, 1); 13 | Matrix* subtracted = subtract(ones, m); 14 | Matrix* multiplied = multiply(m, subtracted); 15 | matrix_free(ones); 16 | matrix_free(subtracted); 17 | return multiplied; 18 | } 19 | 20 | Matrix* softmax(Matrix* m) { 21 | double total = 0; 22 | for (int i = 0; i < m->rows; i++) { 23 | for (int j = 0; j < m->cols; j++) { 24 | total += exp(m->entries[i][j]); 25 | } 26 | } 27 | Matrix* mat = matrix_create(m->rows, m->cols); 28 | for (int i = 0; i < mat->rows; i++) { 29 | for (int j = 0; j < mat->cols; j++) { 30 | mat->entries[i][j] = exp(m->entries[i][j]) / total; 31 | } 32 | } 33 | return mat; 34 | } -------------------------------------------------------------------------------- /neural/activations.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../matrix/matrix.h" 4 | 5 | double sigmoid(double input); 6 | Matrix* sigmoidPrime(Matrix* m); 7 | Matrix* softmax(Matrix* m); -------------------------------------------------------------------------------- /neural/nn.c: -------------------------------------------------------------------------------- 1 | #include "nn.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "../matrix/ops.h" 8 | #include "../neural/activations.h" 9 | 10 | #define MAXCHAR 1000 11 | 12 | // 784, 300, 10 13 | NeuralNetwork* network_create(int input, int hidden, int output, double lr) { 14 | NeuralNetwork* net = malloc(sizeof(NeuralNetwork)); 15 | net->input = input; 16 | net->hidden = hidden; 17 | net->output = output; 18 | net->learning_rate = lr; 19 | Matrix* hidden_layer = matrix_create(hidden, input); 20 | Matrix* output_layer = matrix_create(output, hidden); 21 | matrix_randomize(hidden_layer, hidden); 22 | matrix_randomize(output_layer, output); 23 | net->hidden_weights = hidden_layer; 24 | net->output_weights = output_layer; 25 | return net; 26 | } 27 | 28 | void network_train(NeuralNetwork* net, Matrix* input, Matrix* output) { 29 | // Feed forward 30 | Matrix* hidden_inputs = dot(net->hidden_weights, input); 31 | Matrix* hidden_outputs = apply(sigmoid, hidden_inputs); 32 | Matrix* final_inputs = dot(net->output_weights, hidden_outputs); 33 | Matrix* final_outputs = apply(sigmoid, final_inputs); 34 | 35 | // Find errors 36 | Matrix* output_errors = subtract(output, final_outputs); 37 | Matrix* transposed_mat = transpose(net->output_weights); 38 | Matrix* hidden_errors = dot(transposed_mat, output_errors); 39 | matrix_free(transposed_mat); 40 | 41 | // Backpropogate 42 | // output_weights = add( 43 | // output_weights, 44 | // scale( 45 | // net->lr, 46 | // dot( 47 | // multiply( 48 | // output_errors, 49 | // sigmoidPrime(final_outputs) 50 | // ), 51 | // transpose(hidden_outputs) 52 | // ) 53 | // ) 54 | // ) 55 | Matrix* sigmoid_primed_mat = sigmoidPrime(final_outputs); 56 | Matrix* multiplied_mat = multiply(output_errors, sigmoid_primed_mat); 57 | transposed_mat = transpose(hidden_outputs); 58 | Matrix* dot_mat = dot(multiplied_mat, transposed_mat); 59 | Matrix* scaled_mat = scale(net->learning_rate, dot_mat); 60 | Matrix* added_mat = add(net->output_weights, scaled_mat); 61 | 62 | matrix_free(net->output_weights); // Free the old weights before replacing 63 | net->output_weights = added_mat; 64 | 65 | matrix_free(sigmoid_primed_mat); 66 | matrix_free(multiplied_mat); 67 | matrix_free(transposed_mat); 68 | matrix_free(dot_mat); 69 | matrix_free(scaled_mat); 70 | 71 | // hidden_weights = add( 72 | // net->hidden_weights, 73 | // scale ( 74 | // net->learning_rate 75 | // dot ( 76 | // multiply( 77 | // hidden_errors, 78 | // sigmoidPrime(hidden_outputs) 79 | // ) 80 | // transpose(inputs) 81 | // ) 82 | // ) 83 | // ) 84 | // Reusing variables after freeing memory 85 | sigmoid_primed_mat = sigmoidPrime(hidden_outputs); 86 | multiplied_mat = multiply(hidden_errors, sigmoid_primed_mat); 87 | transposed_mat = transpose(input); 88 | dot_mat = dot(multiplied_mat, transposed_mat); 89 | scaled_mat = scale(net->learning_rate, dot_mat); 90 | added_mat = add(net->hidden_weights, scaled_mat); 91 | matrix_free(net->hidden_weights); // Free the old hidden_weights before replacement 92 | net->hidden_weights = added_mat; 93 | 94 | matrix_free(sigmoid_primed_mat); 95 | matrix_free(multiplied_mat); 96 | matrix_free(transposed_mat); 97 | matrix_free(dot_mat); 98 | matrix_free(scaled_mat); 99 | 100 | // Free matrices 101 | matrix_free(hidden_inputs); 102 | matrix_free(hidden_outputs); 103 | matrix_free(final_inputs); 104 | matrix_free(final_outputs); 105 | matrix_free(output_errors); 106 | matrix_free(hidden_errors); 107 | } 108 | 109 | void network_train_batch_imgs(NeuralNetwork* net, Img** imgs, int batch_size) { 110 | for (int i = 0; i < batch_size; i++) { 111 | if (i % 100 == 0) printf("Img No. %d\n", i); 112 | Img* cur_img = imgs[i]; 113 | Matrix* img_data = matrix_flatten(cur_img->img_data, 0); // 0 = flatten to column vector 114 | Matrix* output = matrix_create(10, 1); 115 | output->entries[cur_img->label][0] = 1; // Setting the result 116 | network_train(net, img_data, output); 117 | matrix_free(output); 118 | matrix_free(img_data); 119 | } 120 | } 121 | 122 | Matrix* network_predict_img(NeuralNetwork* net, Img* img) { 123 | Matrix* img_data = matrix_flatten(img->img_data, 0); 124 | Matrix* res = network_predict(net, img_data); 125 | matrix_free(img_data); 126 | return res; 127 | } 128 | 129 | double network_predict_imgs(NeuralNetwork* net, Img** imgs, int n) { 130 | int n_correct = 0; 131 | for (int i = 0; i < n; i++) { 132 | Matrix* prediction = network_predict_img(net, imgs[i]); 133 | if (matrix_argmax(prediction) == imgs[i]->label) { 134 | n_correct++; 135 | } 136 | matrix_free(prediction); 137 | } 138 | return 1.0 * n_correct / n; 139 | } 140 | 141 | Matrix* network_predict(NeuralNetwork* net, Matrix* input_data) { 142 | Matrix* hidden_inputs = dot(net->hidden_weights, input_data); 143 | Matrix* hidden_outputs = apply(sigmoid, hidden_inputs); 144 | Matrix* final_inputs = dot(net->output_weights, hidden_outputs); 145 | Matrix* final_outputs = apply(sigmoid, final_inputs); 146 | Matrix* result = softmax(final_outputs); 147 | 148 | matrix_free(hidden_inputs); 149 | matrix_free(hidden_outputs); 150 | matrix_free(final_inputs); 151 | matrix_free(final_outputs); 152 | 153 | return result; 154 | } 155 | 156 | void network_save(NeuralNetwork* net, char* file_string) { 157 | mkdir(file_string, 0777); 158 | // Write the descriptor file 159 | chdir(file_string); 160 | FILE* descriptor = fopen("descriptor", "w"); 161 | fprintf(descriptor, "%d\n", net->input); 162 | fprintf(descriptor, "%d\n", net->hidden); 163 | fprintf(descriptor, "%d\n", net->output); 164 | fclose(descriptor); 165 | matrix_save(net->hidden_weights, "hidden"); 166 | matrix_save(net->output_weights, "output"); 167 | printf("Successfully written to '%s'\n", file_string); 168 | chdir("-"); // Go back to the orignal directory 169 | } 170 | 171 | NeuralNetwork* network_load(char* file_string) { 172 | NeuralNetwork* net = malloc(sizeof(NeuralNetwork)); 173 | char entry[MAXCHAR]; 174 | chdir(file_string); 175 | 176 | FILE* descriptor = fopen("descriptor", "r"); 177 | fgets(entry, MAXCHAR, descriptor); 178 | net->input = atoi(entry); 179 | fgets(entry, MAXCHAR, descriptor); 180 | net->hidden = atoi(entry); 181 | fgets(entry, MAXCHAR, descriptor); 182 | net->output = atoi(entry); 183 | fclose(descriptor); 184 | net->hidden_weights = matrix_load("hidden"); 185 | net->output_weights = matrix_load("output"); 186 | printf("Successfully loaded network from '%s'\n", file_string); 187 | chdir("-"); // Go back to the original directory 188 | return net; 189 | } 190 | 191 | void network_print(NeuralNetwork* net) { 192 | printf("# of Inputs: %d\n", net->input); 193 | printf("# of Hidden: %d\n", net->hidden); 194 | printf("# of Output: %d\n", net->output); 195 | printf("Hidden Weights: \n"); 196 | matrix_print(net->hidden_weights); 197 | printf("Output Weights: \n"); 198 | matrix_print(net->output_weights); 199 | } 200 | 201 | void network_free(NeuralNetwork *net) { 202 | matrix_free(net->hidden_weights); 203 | matrix_free(net->output_weights); 204 | free(net); 205 | net = NULL; 206 | } -------------------------------------------------------------------------------- /neural/nn.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../matrix/matrix.h" 4 | #include "../util/img.h" 5 | 6 | typedef struct { 7 | int input; 8 | int hidden; 9 | int output; 10 | double learning_rate; 11 | Matrix* hidden_weights; 12 | Matrix* output_weights; 13 | } NeuralNetwork; 14 | 15 | NeuralNetwork* network_create(int input, int hidden, int output, double lr); 16 | void network_train(NeuralNetwork* net, Matrix* input_data, Matrix* output_data); 17 | void network_train_batch_imgs(NeuralNetwork* net, Img** imgs, int batch_size); 18 | Matrix* network_predict_img(NeuralNetwork* net, Img* img); 19 | double network_predict_imgs(NeuralNetwork* net, Img** imgs, int n); 20 | Matrix* network_predict(NeuralNetwork* net, Matrix* input_data); 21 | void network_save(NeuralNetwork* net, char* file_string); 22 | NeuralNetwork* network_load(char* file_string); 23 | void network_print(NeuralNetwork* net); 24 | void network_free(NeuralNetwork* net); -------------------------------------------------------------------------------- /testing_net/descriptor: -------------------------------------------------------------------------------- 1 | 784 2 | 300 3 | 10 4 | -------------------------------------------------------------------------------- /testing_net/output: -------------------------------------------------------------------------------- 1 | 10 2 | 300 3 | 0.119433 4 | -0.302863 5 | -0.121053 6 | 0.364119 7 | 0.327027 8 | 0.280379 9 | 0.077505 10 | 0.048259 11 | 0.024685 12 | 0.091714 13 | -0.310137 14 | 0.081723 15 | -0.318969 16 | 0.230723 17 | -0.280365 18 | 0.202281 19 | -0.024239 20 | -0.094082 21 | 0.069432 22 | -0.276130 23 | -0.357246 24 | 0.128654 25 | -0.143018 26 | 0.350880 27 | 0.144244 28 | -0.325757 29 | 0.119030 30 | -0.377403 31 | -0.047158 32 | -0.262095 33 | -0.052731 34 | -0.171128 35 | -0.279345 36 | -0.274227 37 | -0.246643 38 | -0.127143 39 | -0.323363 40 | 0.378412 41 | 0.329390 42 | 0.176049 43 | 0.232105 44 | -0.347088 45 | -0.064301 46 | 0.286855 47 | 0.290323 48 | 0.231375 49 | 0.297817 50 | 0.049961 51 | -0.082924 52 | -0.022001 53 | 0.199616 54 | 0.010516 55 | -0.021134 56 | -0.191945 57 | -0.018384 58 | -0.023969 59 | -0.113981 60 | -0.249650 61 | -0.003505 62 | -0.368069 63 | -0.213535 64 | -0.243572 65 | -0.054067 66 | 0.206824 67 | -0.155236 68 | 0.244526 69 | -0.364173 70 | -0.037468 71 | 0.271418 72 | -0.383878 73 | -0.086165 74 | 0.336610 75 | -0.171513 76 | -0.277484 77 | -0.290894 78 | -0.228349 79 | 0.188101 80 | 0.362270 81 | -0.330565 82 | -0.172903 83 | 0.161453 84 | -0.212971 85 | 0.205479 86 | -0.181853 87 | -0.006462 88 | -0.025933 89 | 0.284565 90 | 0.281791 91 | 0.261661 92 | -0.042057 93 | -0.249217 94 | -0.128300 95 | 0.118922 96 | 0.049555 97 | -0.256281 98 | -0.098361 99 | 0.095608 100 | -0.031270 101 | 0.160406 102 | 0.072623 103 | -0.054389 104 | -0.130552 105 | 0.183820 106 | 0.323277 107 | -0.078577 108 | 0.225378 109 | -0.309064 110 | -0.085911 111 | 0.253417 112 | -0.013380 113 | 0.137060 114 | 0.064078 115 | 0.039334 116 | 0.112597 117 | -0.284060 118 | -0.396335 119 | -0.211185 120 | -0.332636 121 | -0.293728 122 | -0.231424 123 | 0.104733 124 | -0.219356 125 | 0.160534 126 | -0.052837 127 | -0.329300 128 | 0.241193 129 | 0.159118 130 | 0.139235 131 | 0.011312 132 | 0.217662 133 | 0.043005 134 | -0.343664 135 | -0.064809 136 | -0.103705 137 | 0.229235 138 | 0.294197 139 | -0.038157 140 | -0.181057 141 | -0.148998 142 | -0.121528 143 | 0.190224 144 | -0.194531 145 | -0.217809 146 | 0.028463 147 | -0.212630 148 | -0.135493 149 | 0.089639 150 | 0.055319 151 | -0.054387 152 | -0.352565 153 | 0.279163 154 | -0.290147 155 | -0.098369 156 | 0.032995 157 | 0.199261 158 | -0.002520 159 | 0.191146 160 | 0.179413 161 | -0.041398 162 | -0.224365 163 | 0.251276 164 | -0.240297 165 | -0.084637 166 | -0.212852 167 | 0.201915 168 | 0.104840 169 | -0.261909 170 | -0.170475 171 | -0.277393 172 | 0.117258 173 | 0.081216 174 | -0.236645 175 | -0.163865 176 | 0.254300 177 | 0.234648 178 | -0.124519 179 | 0.013376 180 | 0.005299 181 | -0.388575 182 | 0.271390 183 | 0.045245 184 | -0.284906 185 | -0.352844 186 | -0.334417 187 | 0.125357 188 | -0.253105 189 | 0.185189 190 | 0.164487 191 | -0.387309 192 | -0.116687 193 | -0.258146 194 | 0.210412 195 | 0.053299 196 | -0.038647 197 | -0.199967 198 | -0.082200 199 | -0.272351 200 | -0.025116 201 | 0.089564 202 | 0.002560 203 | -0.121017 204 | 0.041011 205 | 0.124407 206 | 0.043235 207 | 0.071112 208 | -0.053617 209 | -0.284495 210 | -0.243314 211 | -0.142643 212 | -0.089230 213 | -0.082460 214 | 0.267511 215 | -0.019409 216 | 0.066327 217 | -0.210987 218 | -0.082977 219 | 0.233300 220 | -0.212096 221 | -0.362761 222 | -0.298201 223 | -0.018846 224 | -0.273385 225 | 0.315993 226 | -0.179829 227 | 0.198100 228 | -0.078657 229 | 0.326862 230 | -0.125110 231 | -0.366956 232 | 0.139581 233 | 0.256839 234 | -0.039238 235 | -0.121156 236 | 0.093168 237 | -0.162050 238 | -0.235373 239 | -0.246555 240 | -0.004500 241 | -0.134472 242 | 0.022402 243 | -0.297101 244 | 0.308058 245 | 0.124637 246 | 0.249632 247 | 0.126775 248 | -0.254321 249 | -0.214615 250 | -0.015050 251 | -0.179330 252 | 0.042503 253 | 0.064154 254 | 0.262388 255 | 0.260935 256 | 0.176069 257 | -0.107952 258 | 0.254596 259 | -0.204719 260 | -0.218144 261 | -0.072242 262 | -0.193618 263 | 0.347948 264 | -0.181257 265 | -0.349167 266 | -0.026741 267 | -0.347364 268 | -0.130992 269 | 0.136280 270 | -0.231223 271 | -0.364827 272 | -0.176810 273 | -0.239828 274 | -0.318966 275 | -0.078513 276 | -0.396268 277 | -0.379159 278 | -0.257466 279 | -0.249041 280 | 0.061610 281 | 0.071562 282 | -0.088717 283 | -0.156832 284 | -0.006457 285 | 0.009393 286 | -0.214729 287 | 0.006082 288 | 0.309892 289 | -0.144673 290 | 0.244422 291 | -0.152108 292 | 0.217668 293 | -0.049072 294 | -0.100559 295 | -0.349918 296 | -0.048657 297 | -0.253003 298 | -0.285471 299 | -0.316878 300 | -0.293105 301 | 0.147312 302 | -0.341732 303 | 0.015343 304 | -0.347216 305 | -0.034457 306 | -0.297731 307 | -0.291510 308 | 0.085221 309 | -0.251332 310 | -0.193305 311 | -0.095215 312 | -0.346962 313 | 0.284049 314 | 0.152741 315 | 0.159231 316 | -0.067439 317 | 0.298902 318 | -0.245547 319 | -0.050875 320 | -0.109401 321 | -0.164427 322 | 0.243983 323 | -0.072675 324 | 0.138997 325 | -0.134081 326 | 0.097534 327 | -0.058518 328 | 0.154921 329 | 0.243707 330 | -0.116306 331 | 0.253003 332 | 0.200681 333 | 0.114116 334 | 0.137673 335 | 0.317939 336 | -0.158163 337 | 0.168554 338 | -0.390376 339 | -0.227041 340 | -0.263793 341 | -0.001035 342 | -0.047156 343 | -0.239476 344 | -0.081883 345 | -0.210694 346 | 0.310527 347 | 0.313527 348 | -0.089127 349 | -0.168879 350 | -0.179849 351 | 0.343116 352 | 0.110066 353 | -0.154137 354 | -0.144414 355 | -0.054741 356 | 0.247417 357 | 0.350222 358 | -0.353730 359 | 0.287978 360 | 0.379247 361 | 0.156741 362 | -0.338035 363 | 0.290530 364 | -0.035284 365 | 0.141820 366 | 0.282408 367 | 0.292827 368 | -0.019981 369 | -0.197380 370 | -0.265515 371 | 0.019171 372 | 0.122490 373 | 0.187994 374 | -0.347041 375 | -0.199151 376 | -0.328515 377 | -0.296945 378 | -0.403436 379 | 0.093630 380 | -0.022643 381 | 0.009434 382 | 0.232059 383 | -0.164724 384 | -0.321212 385 | -0.164096 386 | -0.323117 387 | -0.254442 388 | -0.203992 389 | -0.323147 390 | -0.314129 391 | -0.006941 392 | -0.392677 393 | -0.331995 394 | 0.016775 395 | 0.070611 396 | 0.199847 397 | 0.152447 398 | 0.031552 399 | 0.025954 400 | -0.309056 401 | 0.028530 402 | -0.109293 403 | 0.318965 404 | 0.003153 405 | -0.188294 406 | -0.173333 407 | 0.165520 408 | -0.024386 409 | -0.019657 410 | 0.026353 411 | -0.209033 412 | -0.258324 413 | -0.120284 414 | 0.113331 415 | -0.079258 416 | 0.097914 417 | 0.231663 418 | 0.153928 419 | -0.270617 420 | -0.280021 421 | 0.163203 422 | 0.180362 423 | -0.189703 424 | -0.326409 425 | -0.137304 426 | -0.381034 427 | -0.303791 428 | -0.119700 429 | 0.045366 430 | 0.160885 431 | 0.019842 432 | 0.012523 433 | -0.364420 434 | 0.038078 435 | -0.181650 436 | 0.041938 437 | 0.235344 438 | -0.272943 439 | -0.386259 440 | -0.057030 441 | 0.171396 442 | -0.131973 443 | 0.283967 444 | -0.191991 445 | -0.304761 446 | -0.109141 447 | -0.235545 448 | -0.293143 449 | -0.253811 450 | -0.042683 451 | -0.105941 452 | 0.270873 453 | -0.208276 454 | 0.224077 455 | -0.214706 456 | 0.167536 457 | 0.280814 458 | -0.073722 459 | -0.223794 460 | 0.211869 461 | -0.282778 462 | 0.071496 463 | -0.207918 464 | -0.319810 465 | -0.079365 466 | 0.082493 467 | 0.123752 468 | -0.093098 469 | 0.195319 470 | 0.279804 471 | -0.265318 472 | 0.105510 473 | 0.036026 474 | 0.317015 475 | -0.244717 476 | 0.125706 477 | -0.042787 478 | -0.174104 479 | -0.285652 480 | -0.028456 481 | 0.125249 482 | -0.047630 483 | 0.177416 484 | 0.280055 485 | 0.033542 486 | -0.286994 487 | 0.292205 488 | -0.059241 489 | 0.038388 490 | -0.206530 491 | -0.077862 492 | 0.106394 493 | -0.252975 494 | 0.289255 495 | -0.426411 496 | 0.090290 497 | -0.175033 498 | 0.295699 499 | -0.226484 500 | -0.046491 501 | 0.225703 502 | 0.032961 503 | -0.342602 504 | 0.088822 505 | -0.029962 506 | -0.198718 507 | -0.045866 508 | -0.355987 509 | -0.008079 510 | -0.079419 511 | 0.146522 512 | -0.144002 513 | -0.133557 514 | 0.103278 515 | -0.022327 516 | 0.253473 517 | 0.213411 518 | -0.122884 519 | 0.032486 520 | -0.103109 521 | 0.154460 522 | -0.304278 523 | 0.271468 524 | -0.352430 525 | -0.374906 526 | -0.217773 527 | 0.272053 528 | -0.047815 529 | -0.297709 530 | -0.068136 531 | 0.205220 532 | 0.207725 533 | 0.313448 534 | -0.279681 535 | 0.161201 536 | -0.027519 537 | -0.162404 538 | -0.261576 539 | 0.169354 540 | 0.365323 541 | 0.240368 542 | 0.210435 543 | 0.028803 544 | -0.238224 545 | -0.086133 546 | -0.336634 547 | -0.173647 548 | -0.285162 549 | 0.074686 550 | -0.308540 551 | 0.020739 552 | -0.023408 553 | -0.200514 554 | 0.186576 555 | 0.188173 556 | -0.117963 557 | 0.299061 558 | 0.058300 559 | 0.299978 560 | 0.266837 561 | 0.311520 562 | 0.135309 563 | -0.398622 564 | -0.326957 565 | -0.227245 566 | 0.100798 567 | 0.181506 568 | -0.131461 569 | -0.330897 570 | -0.032812 571 | -0.003109 572 | 0.314670 573 | -0.094796 574 | -0.270298 575 | -0.035926 576 | 0.086238 577 | -0.043431 578 | 0.127262 579 | -0.413177 580 | -0.162039 581 | 0.342126 582 | 0.071384 583 | 0.093209 584 | -0.206055 585 | -0.063421 586 | 0.063606 587 | -0.001216 588 | -0.175861 589 | -0.142876 590 | -0.011306 591 | -0.071351 592 | 0.061251 593 | 0.037306 594 | -0.113116 595 | 0.079684 596 | 0.127565 597 | -0.137934 598 | -0.055567 599 | -0.052335 600 | -0.097082 601 | -0.386135 602 | -0.289840 603 | -0.132249 604 | 0.054438 605 | 0.090170 606 | 0.156763 607 | -0.091874 608 | -0.384281 609 | 0.046560 610 | 0.063785 611 | -0.085952 612 | -0.103824 613 | -0.137048 614 | -0.158612 615 | -0.019432 616 | 0.148149 617 | -0.395069 618 | -0.033764 619 | -0.277392 620 | 0.007911 621 | -0.290115 622 | 0.275399 623 | -0.388363 624 | 0.221294 625 | -0.229585 626 | -0.291522 627 | 0.098122 628 | 0.046868 629 | -0.001974 630 | -0.316024 631 | -0.341677 632 | 0.218329 633 | -0.034761 634 | 0.106800 635 | -0.211724 636 | -0.370471 637 | -0.002507 638 | 0.287716 639 | -0.131081 640 | 0.387565 641 | 0.029058 642 | 0.381147 643 | 0.065346 644 | -0.406806 645 | -0.081831 646 | -0.024380 647 | -0.331807 648 | 0.074601 649 | 0.325016 650 | 0.036839 651 | -0.268899 652 | -0.220175 653 | -0.153133 654 | 0.050615 655 | 0.349968 656 | 0.074465 657 | 0.165969 658 | 0.173907 659 | -0.223962 660 | -0.227519 661 | 0.228301 662 | 0.039872 663 | -0.148214 664 | -0.100950 665 | -0.295798 666 | 0.298132 667 | -0.040964 668 | 0.096066 669 | 0.344553 670 | 0.234094 671 | 0.259195 672 | 0.094430 673 | 0.231975 674 | -0.138003 675 | 0.274105 676 | 0.050215 677 | 0.269944 678 | 0.296678 679 | -0.278865 680 | 0.365696 681 | -0.148129 682 | 0.064652 683 | -0.379325 684 | 0.179767 685 | -0.106749 686 | -0.238770 687 | -0.040329 688 | 0.317804 689 | 0.361974 690 | -0.281314 691 | -0.045322 692 | 0.335718 693 | 0.051858 694 | 0.277516 695 | -0.171433 696 | 0.230829 697 | 0.244885 698 | 0.118806 699 | 0.078920 700 | 0.095985 701 | 0.128868 702 | 0.089716 703 | 0.000606 704 | -0.013307 705 | -0.206631 706 | -0.011728 707 | -0.403583 708 | -0.266603 709 | -0.184722 710 | -0.043610 711 | -0.264774 712 | 0.177316 713 | -0.389493 714 | -0.259442 715 | 0.092000 716 | -0.070224 717 | -0.076895 718 | -0.273244 719 | -0.082243 720 | -0.043527 721 | -0.169673 722 | -0.290801 723 | -0.246109 724 | -0.355318 725 | -0.235353 726 | 0.016177 727 | -0.239345 728 | -0.323439 729 | -0.155725 730 | 0.220684 731 | 0.177726 732 | -0.371909 733 | 0.064370 734 | -0.168667 735 | 0.236019 736 | 0.147379 737 | -0.333721 738 | -0.197722 739 | -0.467728 740 | -0.186655 741 | 0.270766 742 | -0.299702 743 | -0.160354 744 | 0.320390 745 | -0.126032 746 | -0.303021 747 | -0.060790 748 | -0.328938 749 | -0.045247 750 | -0.186519 751 | -0.046921 752 | 0.298305 753 | -0.092460 754 | 0.137367 755 | -0.349461 756 | 0.248618 757 | 0.041464 758 | -0.226135 759 | 0.304189 760 | -0.354798 761 | -0.232989 762 | -0.398737 763 | -0.196220 764 | 0.419673 765 | 0.123161 766 | -0.190832 767 | 0.291491 768 | 0.134481 769 | 0.049363 770 | 0.339925 771 | -0.268891 772 | 0.038755 773 | -0.320384 774 | 0.056771 775 | -0.140940 776 | 0.107241 777 | 0.244572 778 | -0.331798 779 | 0.106900 780 | 0.020890 781 | -0.028869 782 | -0.153710 783 | -0.157160 784 | 0.316987 785 | -0.239346 786 | -0.101634 787 | 0.135531 788 | 0.338511 789 | 0.299830 790 | 0.261624 791 | -0.304859 792 | -0.016656 793 | 0.311926 794 | -0.046958 795 | 0.046619 796 | -0.058361 797 | -0.328008 798 | 0.023015 799 | -0.130884 800 | 0.130982 801 | -0.081732 802 | 0.013514 803 | -0.146385 804 | 0.195158 805 | 0.030895 806 | -0.451931 807 | -0.030469 808 | -0.133979 809 | -0.355169 810 | -0.069140 811 | 0.096715 812 | 0.165324 813 | 0.039665 814 | -0.188062 815 | 0.239088 816 | -0.435353 817 | 0.074522 818 | 0.117574 819 | -0.300482 820 | 0.205810 821 | 0.068771 822 | -0.085232 823 | -0.098101 824 | 0.043737 825 | -0.371972 826 | 0.211322 827 | -0.192226 828 | -0.269395 829 | -0.119271 830 | 0.065780 831 | 0.290713 832 | -0.325444 833 | -0.040387 834 | -0.151759 835 | 0.242593 836 | 0.321713 837 | -0.115724 838 | 0.030093 839 | -0.209179 840 | -0.039507 841 | 0.281361 842 | -0.277022 843 | -0.073398 844 | 0.227482 845 | -0.092163 846 | -0.190334 847 | 0.307723 848 | -0.097346 849 | -0.371781 850 | -0.320682 851 | -0.048291 852 | 0.095611 853 | -0.067809 854 | 0.124243 855 | -0.173971 856 | -0.060063 857 | 0.160624 858 | 0.139454 859 | 0.149676 860 | -0.090580 861 | -0.150565 862 | 0.057270 863 | 0.215942 864 | 0.306599 865 | -0.309855 866 | 0.190661 867 | 0.386706 868 | -0.043410 869 | -0.100714 870 | -0.164308 871 | -0.200841 872 | -0.078499 873 | -0.024679 874 | 0.105935 875 | -0.374248 876 | -0.194317 877 | 0.264823 878 | 0.334850 879 | 0.265761 880 | 0.261886 881 | -0.185437 882 | -0.170053 883 | 0.216237 884 | 0.152663 885 | -0.217200 886 | -0.144278 887 | -0.082195 888 | -0.170732 889 | -0.335365 890 | -0.251695 891 | 0.078977 892 | 0.123278 893 | -0.390176 894 | -0.121674 895 | 0.048023 896 | -0.312090 897 | -0.288219 898 | 0.055951 899 | 0.179806 900 | 0.085253 901 | -0.421064 902 | -0.314480 903 | -0.221714 904 | 0.098329 905 | 0.226712 906 | -0.099341 907 | -0.371211 908 | -0.383304 909 | 0.153480 910 | 0.287136 911 | -0.382787 912 | -0.438066 913 | -0.021970 914 | -0.294309 915 | -0.384477 916 | 0.301444 917 | -0.137640 918 | -0.080039 919 | -0.271132 920 | 0.111753 921 | 0.180078 922 | -0.324384 923 | -0.206162 924 | -0.281937 925 | 0.033919 926 | -0.294931 927 | -0.033497 928 | -0.373247 929 | 0.296790 930 | -0.180882 931 | 0.311974 932 | 0.270533 933 | 0.030363 934 | -0.061535 935 | 0.251248 936 | 0.078789 937 | -0.315702 938 | -0.347210 939 | 0.069070 940 | 0.166034 941 | -0.182268 942 | -0.344071 943 | -0.423471 944 | -0.376495 945 | -0.233400 946 | -0.336873 947 | -0.362304 948 | 0.091551 949 | 0.129591 950 | -0.213522 951 | -0.001926 952 | 0.130145 953 | -0.213008 954 | -0.353273 955 | -0.397238 956 | -0.373253 957 | -0.208933 958 | -0.101324 959 | -0.212231 960 | -0.289829 961 | 0.347212 962 | -0.099098 963 | -0.062068 964 | 0.167458 965 | 0.292103 966 | -0.074840 967 | -0.087883 968 | -0.361534 969 | 0.011877 970 | -0.229504 971 | -0.236150 972 | -0.399751 973 | 0.090951 974 | -0.328001 975 | -0.319415 976 | 0.111812 977 | -0.180003 978 | -0.353364 979 | 0.183351 980 | -0.320015 981 | 0.003664 982 | -0.040640 983 | -0.341098 984 | -0.347181 985 | 0.091526 986 | -0.410469 987 | -0.117956 988 | -0.379001 989 | 0.045963 990 | 0.199617 991 | -0.114864 992 | 0.008671 993 | -0.185616 994 | -0.449620 995 | -0.195938 996 | 0.010857 997 | -0.095463 998 | 0.143979 999 | 0.194287 1000 | -0.268820 1001 | -0.268994 1002 | 0.180963 1003 | -0.066464 1004 | 0.180806 1005 | -0.190870 1006 | 0.090704 1007 | 0.240593 1008 | -0.008349 1009 | 0.149729 1010 | 0.072830 1011 | 0.243458 1012 | -0.092522 1013 | -0.160157 1014 | 0.253435 1015 | 0.134356 1016 | -0.313476 1017 | -0.353119 1018 | -0.100490 1019 | -0.212406 1020 | -0.016321 1021 | -0.185366 1022 | 0.361405 1023 | -0.120411 1024 | 0.030917 1025 | 0.256820 1026 | -0.046726 1027 | -0.092334 1028 | -0.035694 1029 | -0.031342 1030 | -0.233998 1031 | 0.257739 1032 | -0.348279 1033 | -0.410162 1034 | -0.135189 1035 | 0.211865 1036 | -0.001219 1037 | -0.326517 1038 | 0.095833 1039 | -0.320226 1040 | -0.252024 1041 | -0.035177 1042 | -0.354746 1043 | -0.356234 1044 | 0.241030 1045 | -0.221236 1046 | 0.252930 1047 | -0.232702 1048 | -0.184169 1049 | -0.211971 1050 | -0.023685 1051 | -0.231442 1052 | 0.000839 1053 | -0.139181 1054 | 0.098124 1055 | -0.093906 1056 | -0.086117 1057 | 0.040516 1058 | 0.193685 1059 | -0.357583 1060 | -0.080802 1061 | -0.261701 1062 | -0.349529 1063 | -0.112544 1064 | 0.016435 1065 | 0.033288 1066 | -0.049227 1067 | -0.357534 1068 | -0.432121 1069 | -0.001230 1070 | -0.072432 1071 | -0.349246 1072 | -0.320607 1073 | 0.083942 1074 | -0.100124 1075 | -0.331348 1076 | -0.398755 1077 | -0.177440 1078 | -0.282659 1079 | -0.039382 1080 | 0.115663 1081 | 0.167939 1082 | 0.121460 1083 | -0.084068 1084 | -0.139312 1085 | 0.087050 1086 | 0.114209 1087 | 0.296383 1088 | -0.240353 1089 | 0.095010 1090 | -0.343846 1091 | 0.042075 1092 | -0.314666 1093 | -0.109190 1094 | -0.210128 1095 | -0.003693 1096 | -0.223908 1097 | 0.265283 1098 | 0.134996 1099 | -0.218604 1100 | -0.036744 1101 | -0.312924 1102 | 0.150791 1103 | 0.022487 1104 | 0.232347 1105 | -0.312018 1106 | 0.131121 1107 | 0.278572 1108 | -0.099974 1109 | -0.297893 1110 | 0.022599 1111 | -0.123043 1112 | -0.213966 1113 | -0.076327 1114 | 0.148735 1115 | 0.230033 1116 | -0.210298 1117 | 0.055300 1118 | 0.221080 1119 | 0.053953 1120 | 0.012147 1121 | -0.314031 1122 | -0.075887 1123 | 0.117561 1124 | -0.060855 1125 | 0.264793 1126 | -0.064724 1127 | 0.213586 1128 | 0.196635 1129 | -0.278260 1130 | -0.147027 1131 | -0.097614 1132 | -0.090663 1133 | -0.299123 1134 | -0.218081 1135 | -0.079351 1136 | -0.121348 1137 | -0.177988 1138 | -0.244944 1139 | 0.242447 1140 | 0.062857 1141 | 0.380737 1142 | -0.091642 1143 | -0.349357 1144 | -0.028036 1145 | -0.316560 1146 | 0.150379 1147 | -0.348741 1148 | -0.324112 1149 | 0.251398 1150 | 0.155739 1151 | 0.173133 1152 | -0.345508 1153 | -0.066821 1154 | 0.107511 1155 | 0.185667 1156 | -0.025266 1157 | -0.225567 1158 | 0.150964 1159 | 0.023090 1160 | -0.094694 1161 | -0.294334 1162 | -0.205911 1163 | 0.214303 1164 | -0.082521 1165 | -0.061158 1166 | -0.170079 1167 | 0.227571 1168 | -0.410265 1169 | 0.134868 1170 | 0.200087 1171 | -0.007218 1172 | 0.339191 1173 | -0.144056 1174 | 0.188351 1175 | 0.087781 1176 | 0.188340 1177 | -0.471808 1178 | 0.199247 1179 | -0.385700 1180 | 0.211711 1181 | 0.170752 1182 | -0.358953 1183 | 0.234234 1184 | -0.028850 1185 | -0.392060 1186 | 0.241240 1187 | -0.293617 1188 | -0.359879 1189 | 0.016624 1190 | 0.228399 1191 | 0.150152 1192 | -0.398419 1193 | -0.261958 1194 | 0.287405 1195 | -0.071507 1196 | 0.252676 1197 | -0.129083 1198 | -0.251296 1199 | 0.286942 1200 | -0.196634 1201 | -0.410740 1202 | 0.093994 1203 | -0.096549 1204 | 0.065684 1205 | 0.085078 1206 | -0.089798 1207 | -0.006978 1208 | 0.208656 1209 | -0.145321 1210 | 0.088784 1211 | 0.177361 1212 | -0.049218 1213 | 0.294601 1214 | -0.322193 1215 | 0.387201 1216 | 0.246271 1217 | 0.271911 1218 | -0.361959 1219 | -0.186379 1220 | -0.016980 1221 | -0.311933 1222 | -0.318621 1223 | 0.220955 1224 | -0.142688 1225 | -0.262677 1226 | -0.263032 1227 | -0.217753 1228 | 0.150753 1229 | 0.043309 1230 | -0.260827 1231 | -0.267667 1232 | 0.152217 1233 | -0.248973 1234 | 0.230334 1235 | -0.061441 1236 | 0.320282 1237 | -0.171319 1238 | -0.353755 1239 | 0.280446 1240 | 0.038676 1241 | 0.278313 1242 | -0.339979 1243 | -0.092785 1244 | 0.249536 1245 | -0.362771 1246 | -0.170926 1247 | 0.094081 1248 | 0.238596 1249 | 0.011488 1250 | -0.274590 1251 | 0.152182 1252 | 0.100514 1253 | -0.147796 1254 | 0.062828 1255 | -0.404076 1256 | 0.162405 1257 | 0.197187 1258 | -0.073119 1259 | -0.110059 1260 | 0.069463 1261 | 0.203099 1262 | 0.204894 1263 | -0.061478 1264 | -0.447481 1265 | 0.076385 1266 | -0.265609 1267 | -0.203054 1268 | -0.307252 1269 | -0.146883 1270 | -0.137108 1271 | -0.484163 1272 | -0.289740 1273 | -0.194430 1274 | -0.146021 1275 | -0.335100 1276 | -0.008037 1277 | 0.123718 1278 | -0.412124 1279 | 0.151336 1280 | -0.184297 1281 | -0.223562 1282 | 0.088920 1283 | -0.225167 1284 | 0.140580 1285 | -0.223031 1286 | -0.004011 1287 | -0.105193 1288 | -0.175695 1289 | -0.367467 1290 | 0.246438 1291 | 0.222765 1292 | -0.402564 1293 | 0.069108 1294 | -0.203761 1295 | -0.172351 1296 | -0.009166 1297 | -0.086715 1298 | 0.060600 1299 | 0.088497 1300 | 0.284420 1301 | -0.397596 1302 | 0.070348 1303 | -0.221299 1304 | 0.046562 1305 | -0.525791 1306 | -0.053620 1307 | -0.045519 1308 | 0.224453 1309 | -0.040072 1310 | -0.241582 1311 | -0.012004 1312 | 0.255884 1313 | 0.431652 1314 | 0.105698 1315 | 0.059559 1316 | -0.176584 1317 | -0.053815 1318 | -0.183452 1319 | 0.002358 1320 | 0.045807 1321 | -0.060477 1322 | 0.041489 1323 | 0.075553 1324 | -0.200326 1325 | -0.450562 1326 | -0.317987 1327 | 0.274384 1328 | 0.090513 1329 | 0.151230 1330 | 0.008624 1331 | -0.075353 1332 | 0.215869 1333 | -0.068477 1334 | 0.287441 1335 | 0.049510 1336 | 0.074850 1337 | -0.107775 1338 | -0.423318 1339 | 0.195327 1340 | -0.334706 1341 | -0.129147 1342 | -0.112945 1343 | 0.352747 1344 | -0.093765 1345 | -0.296333 1346 | 0.269796 1347 | 0.279106 1348 | 0.062798 1349 | -0.221630 1350 | -0.082287 1351 | -0.207482 1352 | -0.038613 1353 | -0.208191 1354 | -0.364833 1355 | 0.235663 1356 | -0.357219 1357 | -0.235409 1358 | 0.085252 1359 | 0.158125 1360 | 0.331943 1361 | -0.087369 1362 | -0.174003 1363 | 0.276965 1364 | -0.399575 1365 | -0.321352 1366 | 0.025214 1367 | 0.161036 1368 | 0.176718 1369 | 0.232633 1370 | -0.017049 1371 | 0.273105 1372 | -0.093909 1373 | 0.340409 1374 | 0.180794 1375 | 0.260088 1376 | -0.191930 1377 | 0.192510 1378 | 0.341478 1379 | 0.224147 1380 | -0.428520 1381 | -0.024173 1382 | -0.269292 1383 | 0.237635 1384 | 0.128114 1385 | -0.118842 1386 | 0.094691 1387 | 0.209842 1388 | -0.005721 1389 | 0.051159 1390 | 0.182041 1391 | 0.118078 1392 | -0.173226 1393 | -0.192059 1394 | 0.046371 1395 | -0.231494 1396 | 0.154326 1397 | -0.210235 1398 | -0.119205 1399 | -0.067111 1400 | -0.127847 1401 | 0.306571 1402 | -0.106324 1403 | 0.130630 1404 | 0.232964 1405 | -0.170636 1406 | 0.278708 1407 | -0.200589 1408 | -0.325360 1409 | 0.186731 1410 | -0.302800 1411 | -0.084738 1412 | -0.183790 1413 | 0.020385 1414 | -0.235356 1415 | -0.233188 1416 | 0.295927 1417 | 0.250227 1418 | -0.307340 1419 | 0.010890 1420 | 0.105031 1421 | -0.403992 1422 | -0.136478 1423 | -0.420310 1424 | 0.084289 1425 | 0.227722 1426 | 0.019835 1427 | -0.161148 1428 | -0.060718 1429 | 0.312367 1430 | 0.323526 1431 | 0.206946 1432 | -0.480015 1433 | -0.137462 1434 | -0.013942 1435 | 0.297456 1436 | 0.070831 1437 | -0.113049 1438 | -0.211525 1439 | -0.358136 1440 | -0.205313 1441 | 0.053338 1442 | -0.020861 1443 | 0.123693 1444 | -0.220991 1445 | 0.107482 1446 | 0.209479 1447 | -0.061823 1448 | 0.099866 1449 | -0.129725 1450 | -0.212823 1451 | -0.139186 1452 | -0.047267 1453 | 0.076063 1454 | 0.025584 1455 | -0.224411 1456 | 0.220690 1457 | -0.195206 1458 | -0.020034 1459 | -0.168691 1460 | -0.225086 1461 | 0.109369 1462 | -0.321583 1463 | -0.257089 1464 | -0.416484 1465 | 0.254845 1466 | -0.163444 1467 | -0.412031 1468 | -0.159766 1469 | 0.151486 1470 | -0.393067 1471 | -0.019144 1472 | -0.043728 1473 | 0.142168 1474 | -0.206015 1475 | 0.331471 1476 | -0.093658 1477 | 0.061543 1478 | -0.079587 1479 | -0.367607 1480 | 0.162007 1481 | 0.238249 1482 | 0.036094 1483 | -0.225736 1484 | 0.133250 1485 | -0.208701 1486 | 0.042065 1487 | 0.092516 1488 | 0.038062 1489 | -0.208656 1490 | -0.271348 1491 | 0.253472 1492 | 0.265914 1493 | -0.072094 1494 | -0.288222 1495 | -0.221496 1496 | -0.161033 1497 | 0.214971 1498 | -0.153018 1499 | 0.272972 1500 | -0.046936 1501 | 0.014901 1502 | -0.039481 1503 | 0.232627 1504 | -0.040849 1505 | -0.303341 1506 | -0.389053 1507 | 0.234581 1508 | 0.090835 1509 | 0.141437 1510 | 0.331275 1511 | -0.032362 1512 | 0.024206 1513 | 0.069131 1514 | 0.391516 1515 | -0.135792 1516 | 0.294094 1517 | -0.017309 1518 | -0.238292 1519 | 0.244750 1520 | 0.240165 1521 | -0.024123 1522 | 0.173096 1523 | 0.335957 1524 | -0.186959 1525 | 0.284367 1526 | -0.294571 1527 | 0.243335 1528 | 0.129857 1529 | 0.163192 1530 | 0.066857 1531 | -0.180347 1532 | -0.183193 1533 | -0.040908 1534 | -0.150274 1535 | 0.034731 1536 | -0.058303 1537 | -0.061025 1538 | 0.123522 1539 | -0.272858 1540 | -0.428446 1541 | 0.039366 1542 | 0.403709 1543 | 0.341505 1544 | -0.027303 1545 | 0.371865 1546 | -0.102516 1547 | 0.080631 1548 | 0.082944 1549 | 0.262338 1550 | -0.065511 1551 | 0.168404 1552 | -0.048654 1553 | -0.404446 1554 | 0.259570 1555 | 0.120934 1556 | -0.167741 1557 | -0.077754 1558 | -0.149705 1559 | 0.351372 1560 | -0.398340 1561 | 0.335362 1562 | -0.256671 1563 | 0.008322 1564 | 0.055535 1565 | 0.106130 1566 | -0.096217 1567 | 0.428875 1568 | -0.183256 1569 | -0.384113 1570 | -0.064786 1571 | 0.096303 1572 | 0.326215 1573 | -0.137956 1574 | 0.028613 1575 | -0.040340 1576 | -0.025937 1577 | -0.148032 1578 | -0.256623 1579 | -0.167043 1580 | -0.413370 1581 | 0.035470 1582 | -0.237402 1583 | 0.120957 1584 | 0.202306 1585 | -0.333781 1586 | -0.208066 1587 | 0.274725 1588 | 0.133441 1589 | 0.259248 1590 | -0.411076 1591 | 0.050926 1592 | -0.355719 1593 | -0.019707 1594 | -0.105838 1595 | 0.041888 1596 | -0.214776 1597 | 0.108275 1598 | 0.156511 1599 | -0.001035 1600 | 0.273377 1601 | -0.317395 1602 | -0.239456 1603 | 0.196429 1604 | 0.090165 1605 | 0.223826 1606 | -0.245572 1607 | -0.225451 1608 | -0.268144 1609 | -0.011195 1610 | 0.308781 1611 | 0.033131 1612 | -0.287101 1613 | 0.229746 1614 | -0.266039 1615 | 0.361074 1616 | -0.206946 1617 | 0.001680 1618 | -0.280087 1619 | 0.304406 1620 | 0.040701 1621 | -0.081509 1622 | 0.133363 1623 | 0.056547 1624 | 0.266089 1625 | 0.357193 1626 | -0.190107 1627 | -0.193839 1628 | 0.147711 1629 | -0.353161 1630 | 0.145738 1631 | 0.296660 1632 | -0.314699 1633 | 0.347613 1634 | 0.188194 1635 | -0.222431 1636 | -0.211833 1637 | -0.366046 1638 | -0.101287 1639 | -0.058463 1640 | 0.114240 1641 | -0.194306 1642 | -0.373366 1643 | 0.288917 1644 | -0.084733 1645 | -0.218141 1646 | -0.299723 1647 | 0.028751 1648 | 0.326300 1649 | -0.144932 1650 | 0.071993 1651 | 0.015614 1652 | 0.204732 1653 | -0.320589 1654 | -0.053238 1655 | 0.171651 1656 | -0.011264 1657 | 0.143715 1658 | 0.230199 1659 | -0.185020 1660 | 0.202418 1661 | 0.184805 1662 | -0.313534 1663 | -0.350667 1664 | 0.206000 1665 | -0.235364 1666 | -0.171001 1667 | -0.397569 1668 | -0.289167 1669 | 0.304319 1670 | 0.075547 1671 | -0.336043 1672 | -0.133408 1673 | 0.273050 1674 | -0.225056 1675 | 0.078599 1676 | -0.441792 1677 | -0.142009 1678 | -0.038876 1679 | -0.274934 1680 | 0.207452 1681 | -0.342846 1682 | 0.290647 1683 | 0.091900 1684 | -0.100660 1685 | -0.163819 1686 | -0.066919 1687 | 0.391323 1688 | -0.173096 1689 | 0.016022 1690 | -0.203179 1691 | -0.369699 1692 | -0.236745 1693 | 0.126108 1694 | -0.107307 1695 | -0.235283 1696 | 0.304565 1697 | 0.215700 1698 | -0.192039 1699 | -0.144099 1700 | 0.227453 1701 | 0.276883 1702 | 0.127060 1703 | -0.357379 1704 | 0.216202 1705 | -0.456384 1706 | 0.229924 1707 | 0.410943 1708 | -0.126003 1709 | -0.060929 1710 | -0.235971 1711 | -0.105282 1712 | 0.082777 1713 | -0.184705 1714 | -0.328395 1715 | -0.200498 1716 | 0.085638 1717 | 0.150851 1718 | -0.294136 1719 | 0.218459 1720 | -0.283322 1721 | 0.104979 1722 | -0.405405 1723 | -0.105749 1724 | -0.060792 1725 | -0.235545 1726 | 0.017730 1727 | 0.036805 1728 | -0.153070 1729 | 0.150496 1730 | 0.338089 1731 | -0.345549 1732 | 0.146844 1733 | 0.045064 1734 | -0.146919 1735 | 0.124727 1736 | 0.084681 1737 | -0.061145 1738 | 0.119474 1739 | -0.229512 1740 | 0.380774 1741 | 0.438125 1742 | 0.052759 1743 | 0.135206 1744 | -0.083082 1745 | 0.165404 1746 | 0.049033 1747 | -0.213953 1748 | 0.017568 1749 | 0.404918 1750 | -0.132303 1751 | 0.183515 1752 | 0.018187 1753 | -0.148834 1754 | 0.390862 1755 | -0.257217 1756 | 0.299363 1757 | 0.147776 1758 | 0.028140 1759 | -0.222079 1760 | 0.084019 1761 | -0.001747 1762 | 0.087999 1763 | 0.028395 1764 | -0.104434 1765 | 0.299408 1766 | -0.159807 1767 | -0.294986 1768 | -0.141247 1769 | 0.383235 1770 | -0.125888 1771 | 0.004156 1772 | -0.355979 1773 | 0.265548 1774 | -0.096244 1775 | 0.160166 1776 | 0.296431 1777 | -0.267898 1778 | -0.207295 1779 | -0.131012 1780 | -0.292855 1781 | 0.027753 1782 | 0.415491 1783 | 0.184037 1784 | -0.270986 1785 | -0.252376 1786 | 0.271905 1787 | 0.274281 1788 | -0.485446 1789 | -0.147442 1790 | -0.206668 1791 | 0.239703 1792 | -0.372323 1793 | 0.328229 1794 | -0.105724 1795 | -0.151388 1796 | 0.404884 1797 | 0.130258 1798 | -0.147414 1799 | 0.016184 1800 | 0.289959 1801 | 0.213764 1802 | -0.140695 1803 | -0.219290 1804 | 0.140757 1805 | 0.155467 1806 | 0.218131 1807 | -0.038250 1808 | 0.220491 1809 | -0.278847 1810 | -0.427720 1811 | -0.264893 1812 | 0.126558 1813 | -0.282773 1814 | 0.226441 1815 | 0.217603 1816 | -0.134561 1817 | 0.306185 1818 | -0.449222 1819 | 0.102225 1820 | -0.038838 1821 | -0.070155 1822 | -0.155960 1823 | 0.007975 1824 | -0.092468 1825 | 0.137160 1826 | -0.432468 1827 | 0.062599 1828 | 0.155653 1829 | 0.021997 1830 | -0.099936 1831 | 0.046780 1832 | -0.136942 1833 | 0.193122 1834 | -0.382837 1835 | -0.315466 1836 | 0.004631 1837 | -0.334542 1838 | 0.222565 1839 | 0.044105 1840 | -0.152080 1841 | 0.211651 1842 | 0.073708 1843 | -0.310348 1844 | -0.394727 1845 | 0.062516 1846 | -0.251167 1847 | -0.007781 1848 | 0.226251 1849 | -0.082720 1850 | -0.276843 1851 | -0.156453 1852 | -0.281893 1853 | 0.085595 1854 | -0.359438 1855 | 0.204022 1856 | 0.170511 1857 | -0.276916 1858 | -0.122390 1859 | -0.078967 1860 | 0.101318 1861 | -0.249992 1862 | -0.210400 1863 | -0.320304 1864 | -0.397802 1865 | -0.205505 1866 | -0.109373 1867 | 0.176460 1868 | -0.200494 1869 | -0.215337 1870 | -0.253274 1871 | -0.383112 1872 | -0.116993 1873 | -0.342666 1874 | -0.170023 1875 | 0.080983 1876 | -0.414781 1877 | 0.190897 1878 | -0.182496 1879 | -0.338996 1880 | -0.080615 1881 | 0.112967 1882 | -0.153240 1883 | 0.053416 1884 | 0.121746 1885 | -0.115945 1886 | -0.046326 1887 | -0.132738 1888 | 0.185450 1889 | -0.327719 1890 | -0.332159 1891 | -0.037598 1892 | -0.172124 1893 | 0.055948 1894 | 0.247022 1895 | 0.072187 1896 | 0.220568 1897 | -0.163492 1898 | -0.060793 1899 | -0.035070 1900 | 0.271563 1901 | 0.265598 1902 | -0.013023 1903 | -0.027090 1904 | -0.273579 1905 | -0.346722 1906 | -0.229756 1907 | -0.071533 1908 | -0.335282 1909 | 0.184127 1910 | -0.049201 1911 | 0.013207 1912 | 0.205390 1913 | -0.409839 1914 | -0.063560 1915 | -0.011053 1916 | -0.027351 1917 | 0.299843 1918 | -0.268758 1919 | 0.076574 1920 | -0.161054 1921 | -0.206810 1922 | -0.304827 1923 | 0.305298 1924 | 0.277266 1925 | -0.317567 1926 | 0.179881 1927 | -0.385644 1928 | 0.150745 1929 | -0.219635 1930 | 0.155439 1931 | 0.292388 1932 | -0.083578 1933 | -0.053725 1934 | -0.053458 1935 | 0.252249 1936 | 0.072199 1937 | 0.297297 1938 | -0.174627 1939 | 0.291090 1940 | 0.294584 1941 | -0.369221 1942 | -0.047751 1943 | 0.152358 1944 | -0.334005 1945 | 0.290493 1946 | 0.011086 1947 | -0.400827 1948 | -0.338080 1949 | 0.163417 1950 | 0.001235 1951 | 0.089770 1952 | -0.174919 1953 | 0.225755 1954 | 0.239518 1955 | -0.058685 1956 | -0.346966 1957 | 0.121551 1958 | 0.083249 1959 | -0.248835 1960 | -0.245527 1961 | 0.133999 1962 | -0.336401 1963 | 0.160729 1964 | -0.253982 1965 | 0.065167 1966 | 0.028015 1967 | 0.263689 1968 | 0.198131 1969 | -0.231604 1970 | -0.396746 1971 | 0.187842 1972 | -0.210753 1973 | -0.011751 1974 | 0.235740 1975 | 0.026989 1976 | 0.072330 1977 | -0.117101 1978 | 0.195541 1979 | -0.389674 1980 | -0.216953 1981 | -0.094038 1982 | 0.083618 1983 | 0.214454 1984 | -0.173255 1985 | 0.073270 1986 | 0.054281 1987 | 0.138941 1988 | 0.091775 1989 | -0.057114 1990 | 0.279810 1991 | 0.261325 1992 | -0.269821 1993 | -0.469637 1994 | 0.178120 1995 | -0.008127 1996 | 0.236423 1997 | 0.093926 1998 | 0.045116 1999 | 0.064400 2000 | 0.237016 2001 | 0.030103 2002 | 0.098784 2003 | -0.108602 2004 | -0.125402 2005 | 0.156054 2006 | -0.355497 2007 | -0.395634 2008 | -0.140092 2009 | 0.299018 2010 | -0.332515 2011 | 0.251277 2012 | -0.185780 2013 | -0.304648 2014 | 0.129276 2015 | 0.113409 2016 | 0.205037 2017 | 0.003223 2018 | 0.126114 2019 | 0.037966 2020 | -0.322675 2021 | 0.113564 2022 | -0.007486 2023 | -0.168910 2024 | 0.300463 2025 | -0.089744 2026 | 0.208526 2027 | 0.156995 2028 | -0.189753 2029 | -0.140845 2030 | 0.050049 2031 | -0.270197 2032 | -0.255075 2033 | -0.044538 2034 | -0.035470 2035 | 0.068524 2036 | -0.202227 2037 | 0.182372 2038 | 0.110241 2039 | 0.075457 2040 | 0.164809 2041 | -0.392868 2042 | 0.185174 2043 | -0.090105 2044 | -0.341808 2045 | 0.001462 2046 | -0.272003 2047 | -0.306821 2048 | -0.181144 2049 | 0.303295 2050 | 0.153077 2051 | 0.010220 2052 | 0.160695 2053 | -0.128060 2054 | 0.208022 2055 | 0.040107 2056 | 0.341326 2057 | 0.112031 2058 | 0.036387 2059 | -0.185698 2060 | -0.111500 2061 | -0.077015 2062 | 0.093467 2063 | 0.071978 2064 | -0.408448 2065 | -0.062643 2066 | -0.204400 2067 | -0.055581 2068 | -0.166911 2069 | -0.193355 2070 | -0.050770 2071 | -0.232835 2072 | -0.150229 2073 | -0.168530 2074 | 0.005326 2075 | -0.028665 2076 | -0.258135 2077 | 0.191887 2078 | 0.215033 2079 | 0.020179 2080 | 0.175290 2081 | 0.080350 2082 | -0.261962 2083 | 0.120526 2084 | -0.187605 2085 | -0.331399 2086 | -0.111257 2087 | -0.257284 2088 | -0.383310 2089 | -0.392064 2090 | 0.055746 2091 | 0.087848 2092 | -0.042921 2093 | -0.144467 2094 | 0.007073 2095 | 0.197731 2096 | 0.109795 2097 | 0.254461 2098 | -0.239961 2099 | -0.150140 2100 | -0.048078 2101 | 0.199377 2102 | -0.038684 2103 | -0.365282 2104 | -0.204252 2105 | -0.235991 2106 | 0.048819 2107 | 0.146749 2108 | -0.281465 2109 | -0.024832 2110 | -0.259852 2111 | -0.377276 2112 | -0.218947 2113 | -0.110768 2114 | 0.166507 2115 | -0.107792 2116 | 0.177965 2117 | -0.196914 2118 | 0.333869 2119 | -0.246759 2120 | -0.080094 2121 | 0.118789 2122 | 0.132677 2123 | -0.303095 2124 | -0.270555 2125 | -0.203814 2126 | 0.375101 2127 | -0.187787 2128 | -0.135426 2129 | -0.079377 2130 | -0.009020 2131 | -0.286248 2132 | -0.070272 2133 | -0.295210 2134 | -0.349929 2135 | 0.217616 2136 | 0.048985 2137 | 0.185335 2138 | 0.025182 2139 | 0.044709 2140 | -0.029113 2141 | 0.296706 2142 | 0.043971 2143 | 0.135370 2144 | 0.029553 2145 | 0.189015 2146 | -0.093089 2147 | -0.046723 2148 | -0.302496 2149 | -0.090937 2150 | -0.048457 2151 | 0.109319 2152 | -0.327747 2153 | 0.016439 2154 | 0.362123 2155 | -0.110476 2156 | -0.444174 2157 | -0.382621 2158 | 0.049766 2159 | 0.073514 2160 | 0.035490 2161 | -0.173134 2162 | 0.268243 2163 | -0.253921 2164 | 0.087427 2165 | 0.265475 2166 | -0.192249 2167 | -0.331730 2168 | 0.281105 2169 | 0.177019 2170 | 0.324427 2171 | -0.058248 2172 | 0.285259 2173 | 0.132904 2174 | -0.179657 2175 | 0.104625 2176 | -0.089803 2177 | 0.180107 2178 | -0.236962 2179 | 0.030770 2180 | -0.211385 2181 | 0.305932 2182 | -0.034627 2183 | 0.059627 2184 | 0.077359 2185 | -0.016441 2186 | -0.393724 2187 | 0.066943 2188 | 0.118192 2189 | 0.155059 2190 | 0.086183 2191 | -0.105760 2192 | -0.217890 2193 | -0.095487 2194 | 0.108221 2195 | 0.312624 2196 | 0.081011 2197 | 0.244895 2198 | -0.217113 2199 | 0.095407 2200 | 0.333669 2201 | -0.292460 2202 | -0.291514 2203 | 0.222359 2204 | 0.226382 2205 | 0.061503 2206 | 0.025010 2207 | 0.166398 2208 | -0.002750 2209 | -0.397426 2210 | -0.031513 2211 | 0.285972 2212 | 0.288080 2213 | 0.293814 2214 | -0.079018 2215 | 0.237248 2216 | -0.083828 2217 | -0.105943 2218 | 0.037139 2219 | -0.123665 2220 | -0.190200 2221 | -0.322822 2222 | 0.037833 2223 | 0.269211 2224 | 0.148918 2225 | 0.038608 2226 | 0.104069 2227 | 0.108478 2228 | -0.031351 2229 | -0.316694 2230 | -0.156853 2231 | -0.098038 2232 | 0.137870 2233 | -0.075507 2234 | -0.052144 2235 | 0.056539 2236 | -0.258563 2237 | -0.113098 2238 | 0.000078 2239 | 0.269798 2240 | -0.074185 2241 | 0.356607 2242 | 0.138598 2243 | -0.033743 2244 | 0.168571 2245 | -0.215364 2246 | -0.104015 2247 | -0.005333 2248 | 0.303231 2249 | -0.250100 2250 | 0.246141 2251 | -0.057778 2252 | -0.034821 2253 | 0.145207 2254 | -0.166979 2255 | -0.097103 2256 | -0.314776 2257 | -0.127472 2258 | 0.383245 2259 | 0.197797 2260 | -0.007988 2261 | 0.038507 2262 | -0.121556 2263 | -0.262668 2264 | -0.306291 2265 | -0.293959 2266 | 0.297883 2267 | -0.156264 2268 | -0.101664 2269 | -0.120273 2270 | -0.102593 2271 | 0.304133 2272 | -0.033971 2273 | -0.116304 2274 | 0.015167 2275 | 0.017942 2276 | 0.062922 2277 | -0.369661 2278 | -0.294260 2279 | 0.059870 2280 | -0.257651 2281 | -0.272075 2282 | -0.224219 2283 | 0.126426 2284 | 0.198725 2285 | 0.071253 2286 | -0.266515 2287 | -0.228877 2288 | -0.467951 2289 | -0.060319 2290 | -0.315250 2291 | 0.156608 2292 | 0.236934 2293 | 0.135077 2294 | 0.247268 2295 | -0.306421 2296 | -0.392221 2297 | -0.353085 2298 | 0.136602 2299 | -0.003895 2300 | 0.085763 2301 | -0.331257 2302 | 0.129823 2303 | -0.260350 2304 | -0.074871 2305 | -0.217404 2306 | 0.250903 2307 | -0.145147 2308 | -0.162229 2309 | -0.397575 2310 | -0.340468 2311 | 0.163820 2312 | -0.197824 2313 | 0.004960 2314 | 0.140820 2315 | -0.195646 2316 | -0.231119 2317 | 0.294701 2318 | 0.185321 2319 | -0.044179 2320 | 0.036109 2321 | -0.269860 2322 | -0.243070 2323 | 0.033517 2324 | -0.361960 2325 | -0.090489 2326 | 0.212817 2327 | -0.206210 2328 | -0.095805 2329 | 0.196976 2330 | 0.338098 2331 | -0.498394 2332 | 0.365502 2333 | 0.095784 2334 | -0.044658 2335 | 0.021189 2336 | -0.253903 2337 | -0.084760 2338 | 0.337699 2339 | 0.207615 2340 | 0.099568 2341 | -0.279918 2342 | -0.001967 2343 | -0.359456 2344 | 0.169738 2345 | -0.202063 2346 | 0.005524 2347 | -0.288219 2348 | -0.010616 2349 | -0.220077 2350 | 0.299840 2351 | -0.317139 2352 | 0.000355 2353 | -0.362179 2354 | 0.255033 2355 | 0.229833 2356 | -0.078481 2357 | 0.191580 2358 | -0.303434 2359 | 0.149629 2360 | -0.088052 2361 | -0.228657 2362 | -0.238607 2363 | -0.132781 2364 | 0.171496 2365 | 0.188772 2366 | -0.230440 2367 | -0.139194 2368 | -0.191436 2369 | -0.326594 2370 | -0.390549 2371 | -0.415187 2372 | -0.028510 2373 | 0.055261 2374 | -0.227533 2375 | -0.047574 2376 | -0.301806 2377 | 0.167629 2378 | 0.270138 2379 | 0.041384 2380 | -0.170444 2381 | 0.187637 2382 | 0.387345 2383 | -0.387725 2384 | 0.253713 2385 | 0.379494 2386 | 0.336706 2387 | 0.043649 2388 | 0.229711 2389 | -0.289484 2390 | 0.053154 2391 | -0.114522 2392 | -0.081772 2393 | 0.151486 2394 | 0.395391 2395 | -0.047265 2396 | 0.024324 2397 | -0.255694 2398 | 0.194765 2399 | 0.275881 2400 | -0.044783 2401 | -0.364873 2402 | -0.398674 2403 | -0.253018 2404 | 0.164981 2405 | -0.250595 2406 | 0.121492 2407 | -0.420696 2408 | -0.148730 2409 | 0.101636 2410 | 0.220222 2411 | 0.032942 2412 | 0.021696 2413 | -0.346020 2414 | 0.073519 2415 | 0.133617 2416 | -0.376540 2417 | 0.402496 2418 | -0.344563 2419 | -0.424377 2420 | -0.241705 2421 | 0.192276 2422 | -0.060449 2423 | 0.161244 2424 | 0.209516 2425 | 0.056179 2426 | -0.115703 2427 | -0.092969 2428 | -0.477390 2429 | -0.048240 2430 | 0.075661 2431 | 0.098612 2432 | 0.085125 2433 | 0.101043 2434 | 0.232279 2435 | 0.033720 2436 | -0.325482 2437 | 0.250721 2438 | -0.427195 2439 | -0.164345 2440 | -0.577795 2441 | -0.304537 2442 | -0.394232 2443 | 0.120299 2444 | -0.198872 2445 | -0.456270 2446 | 0.063389 2447 | 0.047645 2448 | -0.275537 2449 | -0.449639 2450 | 0.150226 2451 | -0.057028 2452 | -0.199615 2453 | 0.055964 2454 | -0.281587 2455 | -0.146925 2456 | 0.040429 2457 | -0.385301 2458 | 0.165424 2459 | -0.042705 2460 | 0.245572 2461 | -0.087688 2462 | -0.250336 2463 | 0.121787 2464 | -0.091212 2465 | -0.152136 2466 | -0.092401 2467 | 0.034163 2468 | -0.095987 2469 | 0.172533 2470 | -0.424778 2471 | 0.006634 2472 | -0.256448 2473 | -0.045657 2474 | -0.070686 2475 | -0.082895 2476 | 0.096533 2477 | -0.211820 2478 | -0.061565 2479 | -0.331474 2480 | -0.011509 2481 | -0.110288 2482 | 0.077950 2483 | -0.279934 2484 | -0.268902 2485 | -0.312157 2486 | 0.074818 2487 | 0.009525 2488 | -0.197873 2489 | 0.154719 2490 | -0.147345 2491 | -0.116027 2492 | 0.076746 2493 | -0.383825 2494 | -0.417531 2495 | -0.274390 2496 | -0.111973 2497 | 0.115741 2498 | -0.356039 2499 | -0.250813 2500 | 0.065891 2501 | -0.167560 2502 | 0.079082 2503 | 0.199121 2504 | 0.121430 2505 | -0.035826 2506 | 0.056157 2507 | -0.373548 2508 | -0.373654 2509 | 0.050323 2510 | -0.373648 2511 | 0.198833 2512 | -0.445581 2513 | 0.268195 2514 | -0.288274 2515 | -0.212401 2516 | -0.123103 2517 | -0.374555 2518 | -0.101163 2519 | -0.434393 2520 | 0.154689 2521 | 0.231589 2522 | -0.199010 2523 | -0.029154 2524 | 0.179596 2525 | -0.267446 2526 | 0.051542 2527 | -0.146292 2528 | 0.054955 2529 | 0.234037 2530 | 0.171552 2531 | -0.145766 2532 | -0.179010 2533 | 0.020753 2534 | 0.019219 2535 | -0.025278 2536 | -0.243975 2537 | 0.004913 2538 | -0.040671 2539 | -0.018322 2540 | -0.263564 2541 | -0.576099 2542 | -0.023138 2543 | -0.296482 2544 | 0.172703 2545 | 0.275159 2546 | 0.091234 2547 | -0.013590 2548 | -0.517459 2549 | -0.247710 2550 | -0.081762 2551 | -0.391037 2552 | -0.164303 2553 | -0.386772 2554 | -0.015196 2555 | -0.179246 2556 | 0.160033 2557 | 0.036818 2558 | -0.405808 2559 | -0.137148 2560 | 0.128498 2561 | -0.425762 2562 | -0.200506 2563 | -0.259763 2564 | 0.223460 2565 | 0.221254 2566 | -0.442415 2567 | -0.255806 2568 | -0.074993 2569 | 0.053703 2570 | -0.390810 2571 | 0.122235 2572 | 0.227299 2573 | 0.031450 2574 | -0.222123 2575 | -0.320129 2576 | 0.008452 2577 | -0.168398 2578 | 0.176732 2579 | 0.138277 2580 | 0.266539 2581 | -0.170543 2582 | 0.250994 2583 | -0.235418 2584 | -0.093892 2585 | 0.141649 2586 | 0.122186 2587 | -0.041827 2588 | -0.070117 2589 | 0.125499 2590 | -0.238394 2591 | -0.220018 2592 | 0.141399 2593 | 0.101630 2594 | 0.143522 2595 | -0.307548 2596 | 0.291249 2597 | 0.305570 2598 | -0.164357 2599 | -0.076874 2600 | 0.112165 2601 | 0.095734 2602 | -0.078412 2603 | 0.125776 2604 | -0.220042 2605 | -0.406892 2606 | 0.297951 2607 | -0.481204 2608 | -0.110018 2609 | 0.369047 2610 | -0.242226 2611 | -0.212634 2612 | -0.341305 2613 | -0.266976 2614 | 0.001668 2615 | 0.192046 2616 | -0.421733 2617 | -0.061081 2618 | 0.069934 2619 | -0.114170 2620 | -0.174883 2621 | -0.182136 2622 | -0.274527 2623 | 0.017596 2624 | -0.336364 2625 | -0.400578 2626 | 0.121901 2627 | -0.348930 2628 | -0.393279 2629 | -0.286635 2630 | 0.102965 2631 | 0.395341 2632 | -0.379067 2633 | -0.018436 2634 | 0.155962 2635 | 0.055789 2636 | -0.036678 2637 | 0.178360 2638 | -0.394405 2639 | -0.178123 2640 | 0.041040 2641 | -0.307956 2642 | 0.174515 2643 | -0.247063 2644 | -0.136886 2645 | 0.099187 2646 | -0.253337 2647 | 0.104713 2648 | -0.177633 2649 | -0.319708 2650 | -0.130548 2651 | -0.412941 2652 | 0.047710 2653 | 0.130331 2654 | 0.206851 2655 | 0.160396 2656 | 0.166185 2657 | 0.148423 2658 | -0.282639 2659 | -0.360571 2660 | -0.191947 2661 | -0.358965 2662 | -0.363812 2663 | -0.241518 2664 | 0.006657 2665 | -0.370271 2666 | -0.292963 2667 | -0.275467 2668 | -0.175999 2669 | -0.145205 2670 | 0.292351 2671 | -0.327007 2672 | -0.363343 2673 | 0.064764 2674 | -0.139385 2675 | 0.019351 2676 | 0.015236 2677 | 0.246275 2678 | 0.197471 2679 | 0.240574 2680 | -0.311795 2681 | -0.111619 2682 | -0.281160 2683 | -0.449279 2684 | -0.265537 2685 | -0.242344 2686 | -0.385675 2687 | -0.129710 2688 | -0.336071 2689 | -0.122587 2690 | -0.116276 2691 | -0.001720 2692 | -0.095800 2693 | -0.006771 2694 | -0.270834 2695 | -0.302803 2696 | 0.114657 2697 | 0.129144 2698 | 0.092085 2699 | -0.279849 2700 | -0.238168 2701 | 0.200548 2702 | -0.112651 2703 | -0.158636 2704 | -0.008306 2705 | 0.359180 2706 | -0.059400 2707 | -0.222326 2708 | -0.430272 2709 | -0.247185 2710 | -0.188510 2711 | -0.112884 2712 | -0.449446 2713 | 0.285394 2714 | 0.099706 2715 | 0.005318 2716 | -0.184134 2717 | 0.293635 2718 | -0.561171 2719 | -0.120641 2720 | -0.272136 2721 | 0.155315 2722 | -0.344142 2723 | 0.045849 2724 | 0.062603 2725 | -0.082957 2726 | -0.481416 2727 | 0.140563 2728 | -0.233811 2729 | -0.258513 2730 | -0.246608 2731 | 0.137653 2732 | -0.305124 2733 | 0.122590 2734 | -0.090540 2735 | 0.090644 2736 | -0.324658 2737 | 0.250469 2738 | -0.314513 2739 | -0.235794 2740 | -0.177497 2741 | 0.126898 2742 | 0.039252 2743 | -0.116353 2744 | 0.225602 2745 | -0.302308 2746 | -0.239053 2747 | -0.312617 2748 | -0.285863 2749 | -0.150460 2750 | 0.008486 2751 | -0.039547 2752 | -0.056090 2753 | 0.220676 2754 | -0.251800 2755 | -0.112129 2756 | -0.051661 2757 | -0.047929 2758 | -0.274815 2759 | 0.407630 2760 | 0.172789 2761 | 0.055122 2762 | 0.361539 2763 | 0.047713 2764 | 0.189703 2765 | -0.049411 2766 | 0.068570 2767 | 0.243680 2768 | -0.195561 2769 | -0.403797 2770 | -0.442481 2771 | 0.192296 2772 | -0.430379 2773 | 0.320498 2774 | -0.078898 2775 | 0.117981 2776 | -0.185809 2777 | 0.207623 2778 | 0.055599 2779 | 0.142917 2780 | -0.163985 2781 | 0.126829 2782 | -0.326837 2783 | 0.159174 2784 | 0.077206 2785 | -0.116385 2786 | -0.229732 2787 | -0.197861 2788 | 0.248818 2789 | -0.192814 2790 | -0.181081 2791 | 0.141316 2792 | -0.287372 2793 | -0.155380 2794 | 0.035280 2795 | -0.188307 2796 | 0.288056 2797 | -0.061633 2798 | -0.266537 2799 | -0.133460 2800 | -0.032395 2801 | -0.030024 2802 | -0.262250 2803 | 0.070721 2804 | -0.115923 2805 | 0.277277 2806 | 0.036140 2807 | 0.219633 2808 | 0.070075 2809 | -0.027363 2810 | -0.073377 2811 | -0.299637 2812 | -0.162555 2813 | 0.123705 2814 | -0.249085 2815 | -0.218034 2816 | -0.057497 2817 | -0.118357 2818 | 0.046368 2819 | 0.005122 2820 | -0.231249 2821 | -0.321910 2822 | -0.014755 2823 | 0.165376 2824 | 0.081033 2825 | -0.375303 2826 | -0.345394 2827 | 0.101409 2828 | 0.030107 2829 | -0.010941 2830 | 0.305514 2831 | -0.180801 2832 | -0.367777 2833 | -0.194548 2834 | -0.412825 2835 | 0.075497 2836 | -0.312670 2837 | 0.286248 2838 | -0.083801 2839 | 0.320286 2840 | -0.033758 2841 | -0.350071 2842 | -0.251962 2843 | -0.360253 2844 | -0.351577 2845 | -0.282464 2846 | -0.150714 2847 | 0.130955 2848 | 0.276742 2849 | 0.203157 2850 | -0.179062 2851 | -0.190584 2852 | -0.305402 2853 | 0.025202 2854 | -0.348407 2855 | 0.164115 2856 | -0.481695 2857 | -0.042548 2858 | -0.015449 2859 | 0.178399 2860 | -0.383938 2861 | 0.128227 2862 | -0.249273 2863 | -0.247362 2864 | -0.455242 2865 | -0.288518 2866 | 0.318934 2867 | 0.081742 2868 | -0.044709 2869 | 0.063081 2870 | 0.005637 2871 | 0.336592 2872 | 0.273106 2873 | -0.441051 2874 | -0.219705 2875 | -0.386365 2876 | -0.038389 2877 | 0.039938 2878 | 0.232648 2879 | -0.123373 2880 | -0.023146 2881 | -0.098089 2882 | -0.114348 2883 | 0.327760 2884 | -0.156192 2885 | 0.199086 2886 | 0.253806 2887 | -0.112884 2888 | -0.160806 2889 | 0.027138 2890 | -0.317332 2891 | 0.119915 2892 | -0.081200 2893 | -0.125098 2894 | 0.279112 2895 | -0.004597 2896 | 0.264995 2897 | 0.054470 2898 | -0.095904 2899 | 0.003260 2900 | 0.073658 2901 | -0.399930 2902 | -0.011305 2903 | -0.031195 2904 | -0.273003 2905 | -0.328786 2906 | 0.231146 2907 | -0.099759 2908 | -0.074742 2909 | 0.456542 2910 | -0.386564 2911 | -0.027737 2912 | -0.147504 2913 | 0.165692 2914 | -0.050116 2915 | -0.020943 2916 | 0.261708 2917 | 0.116758 2918 | 0.240347 2919 | -0.278527 2920 | -0.230510 2921 | -0.319161 2922 | -0.448291 2923 | 0.161667 2924 | 0.143802 2925 | 0.245739 2926 | 0.017876 2927 | 0.223275 2928 | -0.375106 2929 | -0.419546 2930 | -0.063918 2931 | 0.322260 2932 | -0.343634 2933 | -0.178230 2934 | -0.056210 2935 | 0.021785 2936 | -0.234157 2937 | -0.094537 2938 | -0.306777 2939 | -0.369317 2940 | -0.016699 2941 | -0.065965 2942 | 0.034849 2943 | 0.214197 2944 | -0.288816 2945 | -0.329686 2946 | 0.076375 2947 | -0.299414 2948 | 0.206569 2949 | 0.155666 2950 | -0.169122 2951 | -0.197127 2952 | 0.294266 2953 | -0.101686 2954 | -0.184280 2955 | 0.287370 2956 | -0.031424 2957 | 0.308857 2958 | 0.200026 2959 | 0.154513 2960 | -0.260183 2961 | 0.127556 2962 | 0.036909 2963 | -0.095801 2964 | 0.304818 2965 | -0.152703 2966 | -0.235670 2967 | -0.213895 2968 | 0.077410 2969 | -0.155726 2970 | -0.019092 2971 | -0.113481 2972 | -0.234052 2973 | -0.196175 2974 | -0.059724 2975 | -0.074790 2976 | -0.011402 2977 | -0.277708 2978 | 0.107423 2979 | -0.160940 2980 | -0.444221 2981 | -0.194980 2982 | -0.324324 2983 | -0.371896 2984 | 0.208875 2985 | -0.264919 2986 | -0.238975 2987 | -0.065688 2988 | -0.010688 2989 | -0.360167 2990 | -0.176030 2991 | -0.009424 2992 | 0.292675 2993 | -0.225828 2994 | -0.398182 2995 | 0.262886 2996 | -0.041988 2997 | -0.103427 2998 | -0.193221 2999 | -0.048430 3000 | -0.191290 3001 | 0.153825 3002 | -0.357165 3003 | -------------------------------------------------------------------------------- /util/img.c: -------------------------------------------------------------------------------- 1 | #include "img.h" 2 | #include 3 | #include 4 | #include 5 | 6 | #define MAXCHAR 10000 7 | 8 | Img** csv_to_imgs(char* file_string, int number_of_imgs) { 9 | FILE *fp; 10 | Img** imgs = malloc(number_of_imgs * sizeof(Img*)); 11 | char row[MAXCHAR]; 12 | fp = fopen(file_string, "r"); 13 | 14 | // Read the first line 15 | fgets(row, MAXCHAR, fp); 16 | int i = 0; 17 | while (feof(fp) != 1 && i < number_of_imgs) { 18 | imgs[i] = malloc(sizeof(Img)); 19 | 20 | int j = 0; 21 | fgets(row, MAXCHAR, fp); 22 | char* token = strtok(row, ","); 23 | imgs[i]->img_data = matrix_create(28, 28); 24 | while (token != NULL) { 25 | if (j == 0) { 26 | imgs[i]->label = atoi(token); 27 | } else { 28 | imgs[i]->img_data->entries[(j-1) / 28][(j-1) % 28] = atoi(token) / 256.0; 29 | } 30 | token = strtok(NULL, ","); 31 | j++; 32 | } 33 | i++; 34 | } 35 | fclose(fp); 36 | return imgs; 37 | } 38 | 39 | void img_print(Img* img) { 40 | matrix_print(img->img_data); 41 | printf("Img Label: %d\n", img->label); 42 | } 43 | 44 | void img_free(Img* img) { 45 | matrix_free(img->img_data); 46 | free(img); 47 | img = NULL; 48 | } 49 | 50 | void imgs_free(Img** imgs, int n) { 51 | for (int i = 0; i < n; i++) { 52 | img_free(imgs[i]); 53 | } 54 | free(imgs); 55 | imgs = NULL; 56 | } -------------------------------------------------------------------------------- /util/img.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../matrix/matrix.h" 4 | 5 | typedef struct { 6 | Matrix* img_data; 7 | int label; 8 | } Img; 9 | 10 | Img** csv_to_imgs(char* file_string, int number_of_imgs); 11 | void img_print(Img* img); 12 | void img_free(Img *img); 13 | void imgs_free(Img **imgs, int n); 14 | --------------------------------------------------------------------------------