diff options
author | jvech <jmvalenciae@unal.edu.co> | 2023-09-03 16:41:17 -0500 |
---|---|---|
committer | jvech <jmvalenciae@unal.edu.co> | 2023-09-03 16:41:17 -0500 |
commit | bab6d665d98668f67686a3085d7de46204f67366 (patch) | |
tree | ecddf424a25319f4e60509f010284637fd3a3c00 | |
parent | ed930338f7936630705c665cad9dd6d562344efc (diff) |
fix: write network parameter fixed
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | src/nn.c | 3 | ||||
-rw-r--r-- | utils/settings.cfg | 18 |
4 files changed, 14 insertions, 15 deletions
@@ -7,3 +7,4 @@ doc/* !doc/*.tex *.gdb *.gpi +*.bin @@ -23,11 +23,12 @@ build: $(OBJS) run: build @./${BIN} train data/sample_data.json | tee data/train_history.txt - @./${BIN} predict data/sample_data.json | jq -r '.[] | [values[] as $$val | $$val] | @tsv' > ./data/net_data.tsv - @gnuplot -p utils/plot.gpi + @./${BIN} predict data/sample_data.json | jq -r '.[] | [values[] as $$val | $$val] | @tsv' > data/net_data.tsv + @jq -r '.[] | [values[] as $$val | $$val] | @tsv' data/sample_data.json > data/sample_data.tsv + @gnuplot utils/plot.gpi debug: build - gdb -x utils/commands.gdb --tui --args ${BIN} train -a 230 data/sample_data.json -e 150 + gdb -x utils/commands.gdb --tui --args ${BIN} train data/sample_data.json gdb -x utils/commands.gdb --tui --args ${BIN} predict data/sample_data.json clean: @@ -306,6 +306,7 @@ void nn_network_read_weights(char *filepath, Layer *network, size_t network_size if (ret != shape[1]) goto nn_network_read_weights_error; } + fclose(fp); return; nn_network_read_weights_error: @@ -331,7 +332,7 @@ void nn_network_write_weights(char *filepath, Layer *network, size_t network_siz ret = fwrite(network[i].weights, sizeof(double), size, fp); if (ret != size) goto nn_network_write_weights_error; - ret = fwrite(network[i].weights, sizeof(double), network[i].neurons, fp); + ret = fwrite(network[i].bias, sizeof(double), network[i].neurons, fp); if (ret != network[i].neurons) goto nn_network_write_weights_error; } fclose(fp); diff --git a/utils/settings.cfg b/utils/settings.cfg index 00bf040..eee85fc 100644 --- a/utils/settings.cfg +++ b/utils/settings.cfg @@ -1,20 +1,16 @@ [net] loss = square ; options (square) -epochs = 40 ; comment -alpha = 1e-4 +epochs = 200 ; comment +alpha = 1e-2 weights_path = utils/weights.bin -inputs = x, y -labels = z +inputs = x +labels = y ; activation options (relu, sigmoid, softplus, leaky_relu) [layer] -neurons=3 -activation=relu - -[layer] -neurons=4 -activation=relu +neurons=20 +activation=sigmoid [outlayer] -activation = sigmoid +activation = sigmoid |