Skip to content

Commit

Permalink
Add project files
Browse files Browse the repository at this point in the history
  • Loading branch information
g10ria committed Aug 19, 2022
0 parents commit 64af36c
Show file tree
Hide file tree
Showing 29 changed files with 32,977 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.exe
*.zip
*.o
.vscode
*.java
*.classgit
weightsdump.txt
hands/
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CC=gcc
CFLAGS=-I.
DEPS = network.c outputFunctions.c errorFunctions.c activationFunctions.c dibdump.c

%.o: %.c $(DEPS)
$(CC) -o $@ $^ $(CFLAGS)

makenet: network.o outputFunctions.o errorFunctions.o activationFunctions.o dibdump.o
56 changes: 56 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Project Info
This is a set of files that runs a basic neural network.
The main file is `network.c`, and the other files
provide miscellaneous utilities:
`outputFunctions.c` - stores output functions for use in the network
`activationFunctions.c` - stores activation functions for use in the network
`errorFunctions.c` - stores error functions for use in the network
`dibdump.c` - stores utility functions for use with bitmap i/o

Configuration values should be set in a .txt file whose path
is specified during runtime.

# Running the network

```
$ gcc -o network network.c outputFunctions.c errorFunctions.c activationFunctions.c dibdump.c
$ network.exe
```
to compile and run the network; enter the path to the config when prompted.

# Config Structure

```
num_input_nodes 2
num_hidden_layers 1
num_output_nodes 3
hidden_layer_1_size 10 // add lines below this for more hidden layers
trainNetwork Y // whether to train or just run
print_network_specifics Y // whether to print the specific values of the network
print_debug_messages Y // whether to print debug messages while running/training
use_bitmap Y // whether or not to train on a bitmap
original_bitmap_file ./input.bmp // if so, input bitmap file
output_bitmap_file ./output.bmp // if so, output bitmap file
training_sets_file ./inputs.txt // file to store input values (bitmap or not)
where_to_dump_outputs ./outputs.txt // where to dump final/periodic output values
randomize_weights Y // whether to randomize weights
random_weights_lower -0.5 // if randomize: lower bound
random_weights_upper 0.5 // if randomize: upper bound
preset_weights_file ./weights.txt // if not randomize: where to read weights from
where_to_dump_weights ./weightsdump.txt // where to dump final/periodic weights
dump_every_x_iterations 100 // dump weights/nodes every _x_ iterations
initial_learning_factor 0.1
learning_factor_scaler 2.0 // set this to 1.0 to disable adaptive learning
min_learning_factor 0.001 // lower and upper bounds
max_learning_factor 2.0 // for the learning factor
enable_weight_rollback Y // whether or not to enable weight rollback
max_training_iterations 100000 // max # of iterations before stopping training
initial_error 1.0 // what value to initialize the error at
target_training_error 0.00001 // target training error (to stop at)
```
22 changes: 22 additions & 0 deletions activationFunctions.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Gloria Zhu
* Created 9/8/2019
* This file holds a collection of activation functions to be used.
*
* Functions in this file:
*
* identity
*/

#include <stdlib.h>
#include <math.h>

#include "./headerfiles/activationFunctions.h"

/**
* The identity function just returns the exact input.
*/
double identity(double input)
{
return input;
}
Binary file added bitmaps/originalfullsize.bmp
Binary file not shown.
Binary file added bitmaps/originalreducedsize.bmp
Binary file not shown.
Binary file added bitmaps/outputreducedsize - 200I 2000A.bmp
Binary file not shown.
Binary file added bitmaps/outputreducedsize - 250I 250A.bmp
Binary file not shown.
Binary file added bitmaps/outputreducedsize - 5197I 500A.bmp
Binary file not shown.
Binary file added bitmaps/outputreducedsize.bmp
Binary file not shown.
32 changes: 32 additions & 0 deletions configs/andorxorconfig.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
num_input_nodes 2
num_hidden_layers 1
num_output_nodes 3

hidden_layer_1_size 4

trainNetwork Y
print_network_specifics Y
print_debug_messages Y

use_bitmap n
original_bitmap_file ./originalreducedsize.bmp
output_bitmap_file ./outputreducedsize.bmp

training_sets_file ./inputs/allinputs.txt
where_to_dump_outputs ./inputs/temp.txt
randomize_weights Y
random_weights_lower -2
random_weights_upper 2
preset_weights_file ./weights/weights.txt
where_to_dump_weights ./weights/weightsdump.txt
dump_every_x_iterations 10000000000

initial_learning_factor 5
learning_factor_scaler 1.0
min_learning_factor 0.001
max_learning_factor 10
enable_weight_rollback n

max_training_iterations 100
initial_error 1.0
target_training_error 0.00001
33 changes: 33 additions & 0 deletions configs/dibdumpconfig.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
num_input_nodes 3136
num_hidden_layers 2
num_output_nodes 5

hidden_layer_1_size 100
hidden_layer_2_size 100

trainNetwork n
print_network_specifics Y
print_debug_messages Y

use_bitmap n
original_bitmap_file ./bitmaps/originalreducedsize.bmp
output_bitmap_file ./bitmaps/outputreducedsize.bmp

training_sets_file ./inputs/bitmapinputs.txt
where_to_dump_outputs ./inputs/bitmapoutput.txt
randomize_weights Y
random_weights_lower -0.5
random_weights_upper 0.5
preset_weights_file ./weights/weights.txt
where_to_dump_weights ./weights/weightsdump.txt
dump_every_x_iterations 100000

initial_learning_factor 0.1
learning_factor_scaler 1.0
min_learning_factor 0.001
max_learning_factor 5.0
enable_weight_rollback n

max_training_iterations 40000
initial_error 1.0
target_training_error 0.01
32 changes: 32 additions & 0 deletions configs/xorconfig.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
num_input_nodes 2
num_hidden_layers 1
num_output_nodes 1

hidden_layer_1_size 1

trainNetwork Y
print_network_specifics Y
print_debug_messages n

use_bitmap n
original_bitmap_file ./originalreducedsize.bmp
output_bitmap_file ./outputreducedsize.bmp

training_sets_file ./inputs/xorinputs.txt
where_to_dump_outputs ./inputs/temp.txt
randomize_weights Y
random_weights_lower -2
random_weights_upper 2
preset_weights_file ./weights/weights.txt
where_to_dump_weights ./weights/weightsdump.txt
dump_every_x_iterations 10

initial_learning_factor 5
learning_factor_scaler 1.0
min_learning_factor 0.001
max_learning_factor 10
enable_weight_rollback Y

max_training_iterations 10000
initial_error 1.0
target_training_error 0.00001
Loading

0 comments on commit 64af36c

Please sign in to comment.