attractivechaos / kann

A lightweight C library for artificial neural networks
Other
678 stars 117 forks source link

Possible Conv1D and Max1D Issue #6

Open gcmike opened 6 years ago

gcmike commented 6 years ago

Hi there. I am dealing with 1D signal and hence I have modified the mnist-cnn.c example and changed the model like shown below:

kad_node_t *t;
t = kann_layer_input(200);
t = kad_relu(kann_layer_conv1d(t, n_h_flt, 5, 1, 2));
t = kad_max1d(t, 2, 1, 1);
t = kad_relu(kann_layer_conv1d(t, n_h_flt, 5, 1, 2));
t = kad_max1d(t, 2, 1, 1);
t = kann_layer_dense(t, 200);
t = kad_relu(t);
t = kann_layer_dense(t, 100);
t = kad_relu(t);
t = kann_layer_dense(t, 50);
t = kad_relu(t);
ann = kann_new(kann_layer_cost(t, 2, KANN_C_CEB), 0);

I added the padding so as to keep the length. My input is 200 in length and output is a simple true/false. However, when I compile and run training on this, the terminal immediately shows "Segmentation fault: 11." I believe the model to be correct, so I suspect the issue is from 1d-related function?

Thanks in advance!

attractivechaos commented 6 years ago

Did you program segfault before training, or segfault during training?

gcmike commented 6 years ago

Segfault happened before training. Error popped up right after command execution.

gcmike commented 6 years ago

I've done a bit more testing, and found that the segfault happens after the first conv1d and before the first relu. Does this help?