Skip to content

Commit d619cc6

Browse files
committed
test: Add different syntax example to Ex1_SimpleNet
1 parent bf87b9f commit d619cc6

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

examples/Ex1_SimpleNet.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <iostream>
2+
#include "net.h"
3+
using namespace std;
4+
int main(){
5+
/*this example shows how to create simple network in two different ways
6+
the first way is by using preset dimensions, and the second is layer by layer
7+
8+
*/
9+
//using preset dimensions
10+
vector <int> dims{ 3, 5, 4};//specifies the shape of the net. 3 layers: 3 input 5 hidden and 4 output
11+
vector <double> in{ 0, 2, 3};
12+
vector <double> out{ 1, 0, .5, 0};
13+
net n1(dims, true);//creates fully connected net with weights initialized to random values in the shape of dims
14+
n1.TrainBackpropagation( out, in);
15+
16+
17+
//using layer by layer syntax:
18+
net n2;
19+
vector <double> in2{ 0, 2, 3, 1, 4, .6, .5, .4, 0};//new expected output has 9 elements
20+
n2.AddNeurons( 3, 0, "layer1");//layer1 is at the position [0] with 3 neurons
21+
n2.AddNeurons( 5, 1, "layer2");//create 5 neurons in layer at the position [1]
22+
n2.FullyConnect( 0, 1);//fully connect the layers at [0] and [1]
23+
n2.AddNeurons( 4, 2, "layer3"); //create 4 neurons at layer position [2]
24+
n2.FullyConnect( 0, 3);//fully connect layer at [0] to [3] to make the [1] and [2] layers connect to the first
25+
n2.TrainBackpropagation( out, in2);
26+
27+
return 0;
28+
}

examples/SimpleNet.cpp

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)