Skip to content

Commit c85bb14

Browse files
committed
test: add example program for creating a simple network
1 parent 100acc7 commit c85bb14

File tree

10 files changed

+50
-13
lines changed

10 files changed

+50
-13
lines changed

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
HDR_DIR =header
2+
HEADER = $(addprefix -I,$(HDR_DIR))
3+
CCOPTION = Wall std=gnu++11 D__USE_MINGW_ANSI_STDIO=1 pthread
4+
FLAGS = $(addprefix -,$(CCOPTION))
5+
CC = g++
6+
OBJ_DIR =obj
7+
OBJ = link.o data_operations.o net.o neuron.o main.o
8+
BUILD_DIR =bin
9+
SRC_DIR =src
10+
11+
$(BUILD_DIR)/a.out: $(addprefix $(OBJ_DIR)/,$(OBJ))
12+
$(CC) $(FLAGS) $(addprefix $(OBJ_DIR)/,$(OBJ)) -o $(BUILD_DIR)/a.out
13+
14+
$(OBJ_DIR)/link.o: $(SRC_DIR)/link.cpp
15+
$(CC) $(FLAGS) -c $(SRC_DIR)/link.cpp -o $(OBJ_DIR)/link.o $(HEADER)
16+
17+
$(OBJ_DIR)/data_operations.o: $(SRC_DIR)/data_operations.cpp
18+
$(CC) $(FLAGS) -c $(SRC_DIR)/data_operations.cpp -o $(OBJ_DIR)/data_operations.o $(HEADER)
19+
20+
$(OBJ_DIR)/net.o: $(SRC_DIR)/net.cpp
21+
$(CC) $(FLAGS) -c $(SRC_DIR)/net.cpp -o $(OBJ_DIR)/net.o $(HEADER)
22+
23+
$(OBJ_DIR)/neuron.o: $(SRC_DIR)/neuron.cpp
24+
$(CC) $(FLAGS) -c $(SRC_DIR)/neuron.cpp -o $(OBJ_DIR)/neuron.o $(HEADER)
25+
26+
$(OBJ_DIR)/main.o: $(SRC_DIR)/main.cpp
27+
$(CC) $(FLAGS) -c $(SRC_DIR)/main.cpp -o $(OBJ_DIR)/main.o $(HEADER)
28+
29+
30+
clean:
31+
rm $(OBJ_DIR)/*.o
32+
rm $(BUILD_DIR)/*.out

README.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
# neural_network
2-
This is my personal project to make a realatively simple neural network library in C++.
2+
This is my personal project to make a fast and flexible neural network library.
33
I created it specifically with natural language processing in mind, but works well for just about anything, although it is still a work in progress.
44

5-
## Getting Started
6-
### Prerequisites
7-
You will need c++11 support. This works best with g++11 and up. You may need to tell your compiler to use the thread library with the -lpthread option.
8-
9-
```
10-
g++ -std=c++11 foo.cpp -lpthread -o foo
11-
```
12-
### Installing
13-
Download the code and modify the makefile to fit your project.
14-
15-
### Usage
16-
Examples on how to use this library can be found in the examples folder.

bin/a.out

382 KB
Binary file not shown.

examples/README

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Compiling examples (linux)
2+
3+
cd path/to/neural_network
4+
mv examples/ExampleFile.cpp src/main.cpp
5+
make
6+
./bin/a.out

examples/SimpleNet.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <iostream>
2+
#include "net.h"
3+
using namespace std;
4+
int main(){
5+
vector <int> dims{ 3, 5, 4};//specifies the shape of the net. 3 layers: 3 input 5 hidden and 4 output
6+
vector <double> in{ 0, 2, 3};
7+
vector <double> out{ 1, 0, .5, 0};
8+
net n1(dims, true);//creates fully connected net with weights initialized to random values in the shape of dims
9+
n1.TrainBackpropagation( out, in);
10+
return 0;
11+
}

obj/data_operations.o

15.2 KB
Binary file not shown.

obj/link.o

2.78 KB
Binary file not shown.

obj/main.o

47.5 KB
Binary file not shown.

obj/net.o

741 KB
Binary file not shown.

obj/neuron.o

53.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)