Skip to content

Commit eaa53d0

Browse files
committed
updates
1 parent ad71c5d commit eaa53d0

File tree

6 files changed

+15
-18
lines changed

6 files changed

+15
-18
lines changed

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Library supports many operations but more development is needed because currentl
3636
Ceural library is created for multi-layer networks trained using MNIST dataset but with small modifications it can be used for other datasets too. See [Accuracy](#Accuracy) for more info.
3737

3838
# GUI
39+
![GUI](./data/assets/C-digit-recognition-example-of-usage.jpg)
3940

4041
## Control
4142
- `left mouse button & drag` to draw
@@ -67,16 +68,11 @@ Even though Python is much slower than C, Python-digit-recognition is faster. Th
6768
# ToDo
6869
- [ ] add `lag` tests
6970
- [ ] add `ceural` tests
70-
- [x] Cleanup & document `lag` library
71-
- [x] Cleanup & document `ceural` library
7271
- [ ] Cleanup & document `gui`
7372
- [ ] Add icons into `gui`
7473
- [ ] Add command line options to train & test & save & load NN
75-
- [x] Check NN definition during the NN weights & biases load process
7674
- [ ] Create documentation
77-
- [x] Write everything into README
7875
- [ ] Choose license
79-
- [x] Finish top-level 'Makefile' to create final binary for linux
8076
- [ ] Create Windows compilation script & test it on Windows
8177
- [x] Center digit by center of mass of the pixels before feeding it to the neural network from GUI input
8278
- [ ] Use BLAS (for example [OpenBLAS](https://github.com/xianyi/OpenBLAS)) library for linear algebra to improve speed
@@ -87,4 +83,5 @@ Even though Python is much slower than C, Python-digit-recognition is faster. Th
8783
- [MNIST database](http://yann.lecun.com/exdb/mnist/)
8884
- [George Hotz's AI notebook](https://github.com/geohot/ai-notebooks/blob/master/mnist_from_scratch.ipynb)
8985
- [Michael Nielsen's book about neural networks and deep learning](http://neuralnetworksanddeeplearning.com/chap2.html)
90-
- [Artcile about backpropagation from Brilliant.org](https://brilliant.org/wiki/backpropagation/)
86+
- [Artcile about backpropagation from Brilliant.org](https://brilliant.org/wiki/backpropagation/)
87+
- [Epoch vs Batch Size vs Iterations](https://towardsdatascience.com/epoch-vs-iterations-vs-batch-size-4dfb9c7ce9c9)

build/usr/bin/crecog

0 Bytes
Binary file not shown.
119 KB
Loading

lib/ceural/ceural.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,9 @@ ceural_rtn ceural_net_load_from_file(ceural_net_t * nn, const char * filename){
527527

528528
// train accuracy
529529
if(fread(&buf, 2, 1, f) != 1) return CEURAL_PARSE_ERROR;
530-
dbgexec(double test_accuracy = MSB_2bytes_to_int16(buf)/100.0);
530+
double test_accuracy = MSB_2bytes_to_int16(buf)/100.0;
531531

532-
dbg("Network was tested with accuracy: %.2f %%\n", test_accuracy);
532+
printf("Network was tested with accuracy: %.2f %%\n", test_accuracy);
533533

534534
// weights and biases
535535
for(int i = 0; i < nn_size; i ++){

lib/lag/matrix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,8 @@ matrix_size_t matrix_1ubyteMat_mean(const uint8_t* mat, const matrix_size_t rows
10011001
break;
10021002
}
10031003

1004-
printf("m_sum: %d\n", m_sum);
1005-
printf("mr_sum: %d\n", mr_sum);
1004+
//printf("m_sum: %d\n", m_sum);
1005+
//printf("mr_sum: %d\n", mr_sum);
10061006
return round((double)mr_sum / m_sum);
10071007
}
10081008

src/gui.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ static void gui_display_results(const uint8_t results[], const double accuracies
3232
sprintf(text, "%d", results[0]);
3333
gtk_text_buffer_insert_with_tags_by_name(result_buffer, &iter_start, text, -1, "result_format", "top_result", "green", NULL);
3434

35-
sprintf(text, ", accuracy: %.2f %%\n", accuracies[0]);
35+
sprintf(text, ", confidence: %.1f %%\n", accuracies[0]);
3636
gtk_text_buffer_insert_with_tags_by_name(result_buffer, &iter_start, text, -1, "result_format", "top_result", NULL);
3737

3838
// 2. result
39-
sprintf(text, "2.Result: %d, accuracy: %.2f %%\n", results[1], accuracies[1]);
39+
sprintf(text, "2.Result: %d, confidence: %.1f %%\n", results[1], accuracies[1]);
4040
gtk_text_buffer_insert_with_tags_by_name(result_buffer, &iter_start, text, -1, "result_format", "second_result", NULL);
4141

4242
// 3. result
43-
sprintf(text, "3.Result: %d, accuracy: %.2f %%\n", results[2], accuracies[2]);
43+
sprintf(text, "3.Result: %d, confidence: %.1f %%\n", results[2], accuracies[2]);
4444
gtk_text_buffer_insert_with_tags_by_name(result_buffer, &iter_start, text, -1, "result_format", "third_result", NULL);
4545
}
4646

@@ -105,7 +105,7 @@ static void recognise_input(GtkWidget *widget, gpointer data) {
105105

106106
img = gdk_pixbuf_to_uint8_grayscale(pixbuf); // convert image to the grayscale img
107107

108-
matrix_1ubyteMat_display(img, 20, 20);
108+
//matrix_1ubyteMat_display(img, 20, 20);
109109
int row_center = matrix_1ubyteMat_mean(img, 20, 20, ROW_AXIS);
110110
int col_center = matrix_1ubyteMat_mean(img, 20, 20, COL_AXIS);
111111
printf("Center: %dx%d\n", row_center, col_center);
@@ -121,7 +121,7 @@ static void recognise_input(GtkWidget *widget, gpointer data) {
121121

122122
puts("Move done");
123123
dbg("new_size: %dx%d\n", img_final_rows, img_final_cols);
124-
dbgexec(matrix_1ubyteMat_display(img_final, img_final_rows, img_final_cols));
124+
matrix_1ubyteMat_display(img_final, img_final_rows, img_final_cols);
125125

126126
pixbuf = uint8_grayscale_to_gdk_pixbuf(img_final, img_final_rows, img_final_cols);
127127
gui_display_image(pixbuf); // show preprocessed image in result window
@@ -130,15 +130,15 @@ static void recognise_input(GtkWidget *widget, gpointer data) {
130130
nn_recognise(img_final, out_mat);
131131

132132
results[0] = matrix_argmax(out_mat);
133-
accuracies[0] = matrix_max(out_mat);
133+
accuracies[0] = matrix_max(out_mat)*100;
134134
*matrix_at_index(out_mat, results[0]) = -1;
135135

136136
results[1] = matrix_argmax(out_mat);
137-
accuracies[1] = matrix_max(out_mat);
137+
accuracies[1] = matrix_max(out_mat)*100;
138138
*matrix_at_index(out_mat, results[1]) = -1;
139139

140140
results[2] = matrix_argmax(out_mat);
141-
accuracies[2] = matrix_max(out_mat);
141+
accuracies[2] = matrix_max(out_mat)*100;
142142
*matrix_at_index(out_mat, results[2]) = -1;
143143

144144
dbg("RESULT: %d\n", results[0]);

0 commit comments

Comments
 (0)