This a simple C++ fully connected neural network class for Course COMP3046.
ANN.h
: header file for ANN classANN.cpp
: implementation of ANN classANN_Run.cpp
: sample driving program for ANN class
- Defining any configuration of FCNN
- Parrellel computation on CPU
- Save and Load trained model
- Output Loss and Testing accuracy
- Output Epoch time spent
vector<int> cfg = { 28 * 28,100,10 };
The numbers in the vector indicates the numbers of neurons on each layer. In the sample file, there are (28 * 28 =) 784 neurons on input layer, 100 neurons on first (the only) hidden layers, and 10 neurons on output layers.
Construct an ANN instance:
ANN net(cfg);
net.setTestData(test_X, test_Y);
test_X
and test_Y
are vector<vector<float>>
that store the testing X data and testing Y data.
net.train(X_train, y_train, 0.01, 100, 64);
Parameter | Explanation |
---|---|
X_train |
vector< vector<float> > containing training X data |
y_train |
vector< vector<float> > containing training y data |
0.01 |
learning rate |
100 |
Epochs to train |
64 |
Batch size |
net.writeTo("Final_Model");
ANN net("Final_Model");
net.testAccuracy()
Returns accuracy
This is a course project for COMP3046 in HKBU. Thanks to course instructor and teaching assistant.
NI Ronghao ( RogerNi - GitHub )