Skip to content

Commit 9e391c5

Browse files
author
Josiah Laivins
committed
Added header comments
Added big README :) Added gif stuff Fixed the remaining NeuralNetDemo names and changed to FCNeuralNet
1 parent 2d98fba commit 9e391c5

35 files changed

+640
-139
lines changed

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,22 @@ test/Makefile
5757
data/steering_dataset/training/images/
5858
data/steering_dataset/training/steering_angles.csv
5959
/logs/
60+
/cmake_install.cmake
61+
/CMakeCache.txt
62+
/FCNeuralNet
63+
/FCNeuralNet.cbp
64+
/Makefile
65+
/test/googletest-src/
66+
/test/cmake_install.cmake
67+
/test/test
68+
/FCNeuralNet_autogen/
69+
/res/
70+
CMakeFiles/
71+
bin/
72+
lib/
73+
models/
74+
res/
75+
test/CMakeFiles/
76+
test/googletest-build/
77+
test/googletest-download/
78+
test/test_autogen/

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
#
2+
# FCNeuralNet
3+
# Created by Laivins, Josiah https://josiahls.github.io/ on 2019-03-08
4+
#
5+
# This software is provided 'as-is', without any express or implied warranty.
6+
#
7+
# In no event will the author(s) be held liable for any damages arising from the use of this software.
8+
#
9+
# Permission is granted to anyone to use this software for any purpose,
10+
# including commercial applications, and to alter it and redistribute it freely,
11+
# subject to the following restrictions:
12+
# 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
13+
# 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
14+
# 3. This notice may not be removed or altered from any source distribution.
15+
#
116
cmake_minimum_required(VERSION 3.13)
217
project(FCNeuralNet)
318

README.md

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,18 @@ Once done pull the repo from github:
6565

6666
`cmake CMakeLists.txt`
6767
or as I found out using my Mac, I needed to specify the direct path to
68-
the correct cmake (default was 13.12.X), exeample path goes to the currect one:
68+
the correct cmake (default was 13.12.X), example path goes to the correct one:
6969
`/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /Users/jlaivins/CLionProjects/FCNeuralNet`
7070

7171
`make`
7272

7373
Then Hurray! You installed it! This CMakeLists file also is fancy in that it will install
74-
Google Test for you!
74+
Google Test for you! Maybe in the future I can move the Opencv install to the cmake.
75+
76+
As a note, I did not use windows because of the non-linux inputs and just generally not liking the operating system.
77+
If you have issues / trying to install on windows, I can try the best I can to help, but honestly Linux/iOS seems of
78+
more interest to me to support. Of course, if you get it to run on Windows, let me know the commands / issues / links
79+
you used and I can add them to this README.
7580

7681
## Running
7782

@@ -99,11 +104,45 @@ Feel free to go into `/src/executables/NeuralNetRun.cpp` and reference the `trai
99104
performance can be improved by changing the bin size (make larger), adding extra layers (more advanced features?),
100105
and adding more neurons.
101106

107+
You might be interested in the output layer proposals. In the `train` and `run` method, there is commented out code
108+
which runs either is done, will show a window with the raw outputs (kind of cool) (but also kind of ugly...).
109+
```c++
110+
std::printf("\nShowing weight output comparison");
111+
cv::Mat dst;
112+
cv::normalize(nn.layers[0].w, dst, 0, 1, cv::NORM_MINMAX);
113+
dst = dst.reshape(std::get<2>(imageDimension), std::get<0>(imageDimension));
114+
cv::imshow("result",dst);
115+
cv::waitKey(0);
116+
```
117+
118+
Below is kind of what it looks like.
119+
120+
| |
121+
|:---:|
122+
| ![this is something](res/activations.png) |
123+
| |
124+
| *Fig 4: The actual model outputs (Left) have noise due to weight outputs. They gradually become clearer the more epochs are run. The input values (Right) have a gaussian distribution applied to them (hence instead of a single steering angle value, its a range.)* |
125+
102126
`./FCNeuralNet -runNN`
103127
Also free to go into `/src/executables/NeuralNetRun.cpp` and reference the `run` method. However, this method
104128
will produce all the final runs for the visualizer so I would not really want to change much.
105129
106-
`./FCNeuralNet -runVis`
130+
`./FCNeuralNet -runVis`
131+
Directs to `/src/executables/VisualizationBoard.cpp` and you can reference the `run` method. However, unless you
132+
plan to make changes to maybe how the code initializes, I would recommend using a Python approach that I plan to go
133+
with. This visualization object selects the most recent `log` directory, and loads the most recent model from the
134+
`models` directory, so I would recommend you write a python script / notebook that reads directly from there.
135+
* Note, this will live read the graphs, but to load a model (get the nice video) you need to restart the visualizer.
136+
137+
Aaaand the end result should be something like this:
138+
![](res/training_animation_smaller.gif)
139+
140+
| |
141+
|:---:|
142+
| ![this is something](res/activations.png) |
143+
| |
144+
| *Fig 4: The actual model outputs (Left) have noise due to weight outputs. They gradually become clearer the more epochs are run. The input values (Right) have a gaussian distribution applied to them (hence instead of a single steering angle value, its a range.)* |
145+
107146
108147
109148
## Project Structure
@@ -156,8 +195,21 @@ will produce all the final runs for the visualizer so I would not really want to
156195
```
157196

158197
## Contribution guidelines
159-
160-
## For more information
198+
I am most likely going to start a new repo building on this. There are a lot of things I plan to change such as:
199+
- Move NeuralNetRun methods into their own objects / make part of the NeuralNet object
200+
- Drop QT and use Python Jupyter or a Tensorboard log file maker (which means I could keep the project 100% C++)
201+
- Add Dropout Layers
202+
- Add bias (probably the first thing I would add besides better logging)
203+
- Add Convolutional Layers
204+
- Add ReLu and LeakyReLu activation functions to experiment with.
205+
- Remove "FCNeuralNet" constants from the writers and dataset objects. Use CMake to insert them as Macros
206+
- Initially tried doing this, but did not want to spend a whole day working on something that really did not seem
207+
like as big of an issue and the 1000 other things I needed to work in.
208+
- Add more datasets
209+
- I want to add MNIST and FashionMNIST
210+
211+
Feel free to do PRs / Forks of this repo. Let me know if there are any changes. If they are big,
212+
I might go ahead and jump start a new repo. For questions the issues tracker is always good.
161213

162214
## License
163215

main.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* FCNeuralNet
3+
* Created by Laivins, Josiah https://josiahls.github.io/ on 2019-03-08
4+
*
5+
* This software is provided 'as-is', without any express or implied warranty.
6+
*
7+
* In no event will the author(s) be held liable for any damages arising from the use of this software.
8+
*
9+
* Permission is granted to anyone to use this software for any purpose,
10+
* including commercial applications, and to alter it and redistribute it freely,
11+
* subject to the following restrictions:
12+
* 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
13+
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
14+
* 3. This notice may not be removed or altered from any source distribution.
15+
*/
116

217
#include <cstdio>
318
#include <string>

src/executables/NeuralNetRun.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
//
2-
// Created by Laivins, Josiah on 2019-03-16.
3-
//
1+
/**
2+
* FCNeuralNet
3+
* Created by Laivins, Josiah https://josiahls.github.io/ on 2019-03-08
4+
*
5+
* This software is provided 'as-is', without any express or implied warranty.
6+
*
7+
* In no event will the author(s) be held liable for any damages arising from the use of this software.
8+
*
9+
* Permission is granted to anyone to use this software for any purpose,
10+
* including commercial applications, and to alter it and redistribute it freely,
11+
* subject to the following restrictions:
12+
* 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
13+
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
14+
* 3. This notice may not be removed or altered from any source distribution.
15+
*/
16+
417

518
#include <iostream>
619
#include "../utils/DebugHelpers.h"

src/executables/NeuralNetRun.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
1-
//
2-
// Created by Laivins, Josiah on 2019-03-16.
3-
//
1+
/**
2+
* FCNeuralNet
3+
* Created by Laivins, Josiah https://josiahls.github.io/ on 2019-03-08
4+
*
5+
* This software is provided 'as-is', without any express or implied warranty.
6+
*
7+
* In no event will the author(s) be held liable for any damages arising from the use of this software.
8+
*
9+
* Permission is granted to anyone to use this software for any purpose,
10+
* including commercial applications, and to alter it and redistribute it freely,
11+
* subject to the following restrictions:
12+
* 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
13+
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
14+
* 3. This notice may not be removed or altered from any source distribution.
15+
*/
416

5-
#ifndef NEURALNETDEMO_NEURALNETRUN_H
6-
#define NEURALNETDEMO_NEURALNETRUN_H
17+
18+
#ifndef FCNEURALNET_NEURALNETRUN_H
19+
#define FCNEURALNET_NEURALNETRUN_H
720

821
namespace nn {
922
int train(int argc, char **argv);
1023

1124
int run(int argc, char **argv);
1225
}
1326

14-
#endif //NEURALNETDEMO_NEURALNETRUN_H
27+
#endif //FCNEURALNET_NEURALNETRUN_H

src/executables/VisualizationBoard.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
//
2-
// Created by Laivins, Josiah on 2019-03-15.
3-
//
1+
/**
2+
* FCNeuralNet
3+
* Created by Laivins, Josiah https://josiahls.github.io/ on 2019-03-08
4+
*
5+
* This software is provided 'as-is', without any express or implied warranty.
6+
*
7+
* In no event will the author(s) be held liable for any damages arising from the use of this software.
8+
*
9+
* Permission is granted to anyone to use this software for any purpose,
10+
* including commercial applications, and to alter it and redistribute it freely,
11+
* subject to the following restrictions:
12+
* 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
13+
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
14+
* 3. This notice may not be removed or altered from any source distribution.
15+
*/
16+
417

518
#include <cstdio>
619
#include <QApplication>

src/executables/VisualizationBoard.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1-
//
2-
// Created by Laivins, Josiah on 2019-03-16.
3-
//
1+
/**
2+
* FCNeuralNet
3+
* Created by Laivins, Josiah https://josiahls.github.io/ on 2019-03-08
4+
*
5+
* This software is provided 'as-is', without any express or implied warranty.
6+
*
7+
* In no event will the author(s) be held liable for any damages arising from the use of this software.
8+
*
9+
* Permission is granted to anyone to use this software for any purpose,
10+
* including commercial applications, and to alter it and redistribute it freely,
11+
* subject to the following restrictions:
12+
* 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
13+
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
14+
* 3. This notice may not be removed or altered from any source distribution.
15+
*/
416

5-
#ifndef NEURALNETDEMO_VISUALIZATIONBOARD_H
6-
#define NEURALNETDEMO_VISUALIZATIONBOARD_H
17+
18+
#ifndef FCNEURALNET_VISUALIZATIONBOARD_H
19+
#define FCNEURALNET_VISUALIZATIONBOARD_H
720

821
namespace boardViz {
922
int run(int argc, char *argv[]);
1023
}
1124

12-
#endif //NEURALNETDEMO_VISUALIZATIONBOARD_H
25+
#endif //FCNEURALNET_VISUALIZATIONBOARD_H

src/layers/Dimension.h

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
1-
//
2-
// Created by Laivins, Josiah on 2019-03-05.
3-
//
1+
/**
2+
* FCNeuralNet
3+
* Created by Laivins, Josiah https://josiahls.github.io/ on 2019-03-08
4+
*
5+
* This software is provided 'as-is', without any express or implied warranty.
6+
*
7+
* In no event will the author(s) be held liable for any damages arising from the use of this software.
8+
*
9+
* Permission is granted to anyone to use this software for any purpose,
10+
* including commercial applications, and to alter it and redistribute it freely,
11+
* subject to the following restrictions:
12+
* 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
13+
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
14+
* 3. This notice may not be removed or altered from any source distribution.
15+
*/
416

5-
#ifndef NEURALNETDEMO_DIMENSION_H
6-
#define NEURALNETDEMO_DIMENSION_H
17+
18+
#ifndef FCNEURALNET_DIMENSION_H
19+
#define FCNEURALNET_DIMENSION_H
720

821
struct Dimension {
922
int currentLayerSize;
1023
int nextLayerSize;
1124
};
1225

13-
#endif //NEURALNETDEMO_DIMENSION_H
26+
#endif //FCNEURALNET_DIMENSION_H

src/layers/Layer.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1+
/**
2+
* FCNeuralNet
3+
* Created by Laivins, Josiah https://josiahls.github.io/ on 2019-03-08
4+
*
5+
* This software is provided 'as-is', without any express or implied warranty.
6+
*
7+
* In no event will the author(s) be held liable for any damages arising from the use of this software.
8+
*
9+
* Permission is granted to anyone to use this software for any purpose,
10+
* including commercial applications, and to alter it and redistribute it freely,
11+
* subject to the following restrictions:
12+
* 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
13+
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
14+
* 3. This notice may not be removed or altered from any source distribution.
15+
*/
116

2-
//
3-
// Created by Laivins, Josiah on 2019-03-07.
4-
//
517

618
#include <utility>
719
#include <string>

src/layers/Layer.h

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1-
//
2-
// Created by Laivins, Josiah on 2019-03-07.
3-
//
1+
/**
2+
* FCNeuralNet
3+
* Created by Laivins, Josiah https://josiahls.github.io/ on 2019-03-08
4+
*
5+
* This software is provided 'as-is', without any express or implied warranty.
6+
*
7+
* In no event will the author(s) be held liable for any damages arising from the use of this software.
8+
*
9+
* Permission is granted to anyone to use this software for any purpose,
10+
* including commercial applications, and to alter it and redistribute it freely,
11+
* subject to the following restrictions:
12+
* 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
13+
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
14+
* 3. This notice may not be removed or altered from any source distribution.
15+
*/
416

5-
#ifndef NEURALNETDEMO_LAYER_H
6-
#define NEURALNETDEMO_LAYER_H
17+
#ifndef FCNEURALNET_LAYER_H
18+
#define FCNEURALNET_LAYER_H
719

820

921
#include <opencv2/core/mat.hpp>
@@ -91,4 +103,4 @@ class Layer {
91103
};
92104

93105

94-
#endif //NEURALNETDEMO_LAYER_H
106+
#endif //FCNEURALNET_LAYER_H

src/nn/NeuralNet.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
//
2-
// Created by Laivins, Josiah on 2019-03-05.
3-
//
1+
/**
2+
* FCNeuralNet
3+
* Created by Laivins, Josiah https://josiahls.github.io/ on 2019-03-08
4+
*
5+
* This software is provided 'as-is', without any express or implied warranty.
6+
*
7+
* In no event will the author(s) be held liable for any damages arising from the use of this software.
8+
*
9+
* Permission is granted to anyone to use this software for any purpose,
10+
* including commercial applications, and to alter it and redistribute it freely,
11+
* subject to the following restrictions:
12+
* 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
13+
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
14+
* 3. This notice may not be removed or altered from any source distribution.
15+
*/
16+
417

518
#include "NeuralNet.h"
619

0 commit comments

Comments
 (0)