Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "Debug NeuralNetwork Main",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/src/neuralnetwork/main",
"program": "${workspaceFolder}/examples/main",
"args": ["-g", "-O0"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
Expand Down
20 changes: 14 additions & 6 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
"-fdiagnostics-color=always",
"-DMYODDWEB_PROFILE=0",
"-O3",
"${workspaceFolder}/src/neuralnetwork/*.cpp",
"${workspaceFolder}/src/neuralnetwork/libraries/*.cpp",
"${workspaceFolder}/examples/*.cpp",
"${workspaceFolder}/include/neuralnetwork/*.cpp",
"${workspaceFolder}/include/neuralnetwork/layers/*.cpp",
"${workspaceFolder}/include/neuralnetwork/helpers/*.cpp",
"${workspaceFolder}/include/neuralnetwork/common/*.cpp",
"${workspaceFolder}/include/neuralnetwork/libraries/TinyJSON.cpp",
"-o",
"${fileDirname}/main"
"${workspaceFolder}/examples/main"
],
"options": {
"cwd": "${fileDirname}"
Expand Down Expand Up @@ -46,10 +50,14 @@
"-Wtype-limits",
"-DMYODDWEB_PROFILE=0",
"-O0",
"${workspaceFolder}/src/neuralnetwork/*.cpp",
"${workspaceFolder}/src/neuralnetwork/libraries/*.cpp",
"${workspaceFolder}/examples/*.cpp",
"${workspaceFolder}/include/neuralnetwork/*.cpp",
"${workspaceFolder}/include/neuralnetwork/layers/*.cpp",
"${workspaceFolder}/include/neuralnetwork/helpers/*.cpp",
"${workspaceFolder}/include/neuralnetwork/common/*.cpp",
"${workspaceFolder}/include/neuralnetwork/libraries/TinyJSON.cpp",
"-o",
"${fileDirname}/main"
"${workspaceFolder}/examples/main"
],
"options": {
"cwd": "${fileDirname}"
Expand Down
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog

All notable changes to the `neural-network` library will be documented in this file.

## [1.1.0] - 2026-06-12

### Added
- Created the `myoddweb::nn` namespace.
- Wrapped all core neural network library classes, structures, and helper functions in the new `myoddweb::nn` namespace (including `NeuralNetwork`, `Layer`, `Neuron`, `activation`, `NeuralNetworkOptions`, etc.).
- Added explicit documentation in the `README.md` explaining how to import and use the new namespace.

### Changed
- Updated all stand-alone example header files in `src/neuralnetwork/examples/` to use the `myoddweb::nn` namespace.
- Updated all test files in `tests/` to use the `myoddweb::nn` namespace.
- Kept third-party libraries (`TinyJSON`, `tracy`) and instrumentation code (`instrumentor.h`) outside the namespace to maintain clean integration boundaries.
- Reorganised the core NeuralNetwork library directory structure from a flat root layout into `/layers/`, `/helpers/`, and `/common/` subdirectories to improve code modularity.
- Updated all include directives in library headers, source files, tests, and examples to point to the new subdirectory paths.
- Updated MSVC Visual Studio project files (`.vcxproj` and `.vcxproj.filters`) and CMake files (`CMakeLists.txt`) to reflect the new folder structure.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ While not focused on high performance, it provides a clean implementation of the

## How to use

### Namespace

All classes, structures, and functions of the core neural network library are wrapped in the `myoddweb::nn` namespace.

To use the library, you can import the namespace:

```cpp
using namespace myoddweb::nn;
```

Or reference the types explicitly:

```cpp
myoddweb::nn::NeuralNetworkOptions options = ...
myoddweb::nn::NeuralNetwork nn(options);
```

### Activation methods

* linear
Expand Down Expand Up @@ -252,6 +269,18 @@ To enable these optimizations, ensure your compiler is configured to target the

For more information on AVX2, see the [Intel Intrinsics Guide](https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html) or [Wikipedia](https://en.wikipedia.org/wiki/Advanced_Vector_Extensions).

## Repository Layout

* `\include\neuralnetwork\`: The stand-alone core neural network library (including `/layers/`, `/helpers/`, and `/common/` subdirectories).
* `\examples\`: Standalone example implementations, runner (`main.cpp`), and the main Visual Studio solution (`neuralnetwork.sln`).
* `\tests\`: Comprehensive unit test suite.

## Building and Running

1. Open `examples/neuralnetwork.sln` in Visual Studio 2022.
2. Select `neuralnetwork` (to run the examples) or `neuralnetwork_tests` (to run unit tests) as the startup project.
3. Build and run using the IDE.

## Technical Stack

* **Language:** C++17/C++20
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#pragma once
#pragma once

#include "helper.h"
#include "../errorcalculation.h"
#include "../logger.h"
#include "../neuralnetworkserializer.h"
#include "helpers/errorcalculation.h"
#include "common/logger.h"
#include "helpers/neuralnetworkserializer.h"
#include <vector>
#include <random>
#include <iomanip>


using namespace myoddweb::nn;
class ExampleAddingProblem
{
public:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#pragma once
#pragma once
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include "../neuralnetwork.h"
#include "../neuralnetworkserializer.h"
#include "../logger.h"
#include "neuralnetwork.h"
#include "helpers/neuralnetworkserializer.h"
#include "common/logger.h"


using namespace myoddweb::nn;
class ExampleBranchedOutput
{
public:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "../errorcalculation.h"
#include "../logger.h"
#include "../neuralnetworkserializer.h"
#pragma once
#include "helpers/errorcalculation.h"
#include "common/logger.h"
#include "helpers/neuralnetworkserializer.h"
#include "helper.h"
#include <iomanip>
#include <numeric>
Expand All @@ -21,6 +21,8 @@
* This confirms that Softmax, compound slicing, multi-head hidden layers,
* recurrent states, residual jumps, and persistence all work in perfect harmony.
*/

using namespace myoddweb::nn;
class ExampleCompoundOutputSandwich
{
private:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "../errorcalculation.h"
#include "../logger.h"
#include "../neuralnetwork.h"
#pragma once
#include "helpers/errorcalculation.h"
#include "common/logger.h"
#include "neuralnetwork.h"
#include "helper.h"
#include <vector>
#include <cmath>
Expand All @@ -21,6 +21,8 @@
* - Bucket 3: 0.4 <= x < 1.2
* - Bucket 4: x >= 1.2
*/

using namespace myoddweb::nn;
class ExampleCompoundSoftmax
{
private:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#pragma once
#include "../errorcalculation.h"
#include "../logger.h"
#include "../neuralnetworkserializer.h"
#pragma once
#include "helpers/errorcalculation.h"
#include "common/logger.h"
#include "helpers/neuralnetworkserializer.h"
#include "helper.h"
#include <iomanip>

// Compound

using namespace myoddweb::nn;
class ExampleCompoundTrivialSoftmax
{
private:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include <vector>
#include <vector>
#include <random>

#include "../logger.h"
#include "../neuralnetwork.h"
#include "common/logger.h"
#include "neuralnetwork.h"
#include "helper.h"


using namespace myoddweb::nn;
class ExampleCopyMemory
{
public:
Expand Down
2 changes: 1 addition & 1 deletion src/neuralnetwork/examples/helper.h → examples/helper.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <chrono>
#include <chrono>
#include <string>

#define TEST_START(label) \
Expand Down
8 changes: 5 additions & 3 deletions src/neuralnetwork/examples/lstm.h → examples/lstm.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#pragma once
#include "../neuralnetwork.h"
#include "../neuralnetworkoptions.h"
#include "../logger.h"
#include "neuralnetwork.h"
#include "neuralnetworkoptions.h"
#include "common/logger.h"
#include "helper.h"
#include <vector>


using namespace myoddweb::nn;
class ExampleLstm
{
private:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "../neuralnetwork.h"
#include "../neuralnetworkoptions.h"
#include "../logger.h"
#pragma once
#include "neuralnetwork.h"
#include "neuralnetworkoptions.h"
#include "common/logger.h"
#include "helper.h"
#include <vector>

Expand All @@ -13,6 +13,8 @@
*
* It is used to verify the integration of LSTM with Multi-Output functionality.
*/

using namespace myoddweb::nn;
class ExampleLstmMulti
{
private:
Expand Down
44 changes: 23 additions & 21 deletions src/neuralnetwork/main.cpp → examples/main.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
// neuralnetwork.cpp : This file contains the 'main' function. Program execution begins and ends there.
// neuralnetwork.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include "logger.h"
#include "common/logger.h"

// neural network
#include "neuralnetwork.h"

// examples
#include "./examples/addingproblem.h"
#include "./examples/branched_output.h"
#include "./examples/compound_output_sandwich.h"
#include "./examples/compound_softmax.h"
#include "./examples/compound_trivial_softmax.h"
#include "./examples/copymemory.h"
#include "./examples/lstm.h"
#include "./examples/lstm_multi.h"
#include "./examples/multi_output.h"
#include "./examples/multi_output_gru.h"
#include "./examples/repro_issue.h"
#include "./examples/residualxor.h"
#include "./examples/spiral.h"
#include "./examples/syntheticsentiment.h"
#include "./examples/threebitparity.h"
#include "./examples/trivial_softmax.h"
#include "./examples/twomoon.h"
#include "./examples/xor.h"
#include "./libraries/instrumentor.h"
#include "addingproblem.h"
#include "branched_output.h"
#include "compound_output_sandwich.h"
#include "compound_softmax.h"
#include "compound_trivial_softmax.h"
#include "copymemory.h"
#include "lstm.h"
#include "lstm_multi.h"
#include "multi_output.h"
#include "multi_output_gru.h"
#include "repro_issue.h"
#include "residualxor.h"
#include "spiral.h"
#include "syntheticsentiment.h"
#include "threebitparity.h"
#include "trivial_softmax.h"
#include "twomoon.h"
#include "xor.h"
#include "libraries/instrumentor.h"

using namespace myoddweb::nn;

int main()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "../errorcalculation.h"
#include "../logger.h"
#include "../neuralnetwork.h"
#pragma once
#include "helpers/errorcalculation.h"
#include "common/logger.h"
#include "neuralnetwork.h"
#include "helper.h"
#include <vector>
#include <cmath>
Expand All @@ -19,6 +19,8 @@
* - Output ~1.0 if x > 0, ~0.0 if x < 0 (Sigmoid)
* - Output tanh(x) as a regression value (Tanh)
*/

using namespace myoddweb::nn;
class ExampleMultiOutput
{
private:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "../errorcalculation.h"
#include "../logger.h"
#include "../neuralnetwork.h"
#pragma once
#include "helpers/errorcalculation.h"
#include "common/logger.h"
#include "neuralnetwork.h"
#include "helper.h"
#include <vector>
#include <cmath>
Expand All @@ -18,6 +18,8 @@
* 1. Sigmoid Output: Is the LAST value in the sequence positive?
* 2. Tanh Output: What is the average value of the sequence?
*/

using namespace myoddweb::nn;
class ExampleMultiOutputGru
{
private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "neuralnetwork", "neuralnetw
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "neuralnetwork_tests", "..\..\tests\neuralnetwork_tests.vcxproj", "{A3D2B8F3-6B23-4F26-990C-26CC4C33BE4B}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "neuralnetwork_tests", "..\tests\neuralnetwork_tests.vcxproj", "{A3D2B8F3-6B23-4F26-990C-26CC4C33BE4B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Loading
Loading