# nuistmrchest/libchestneuralnetwork architecture

> Architecture diagram of the GitHub repository nuistmrchest/libchestneuralnetwork, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nuistmrchest/libchestneuralnetwork
- Repository: https://github.com/nuistmrchest/libchestneuralnetwork

## Overview

LibChestNN is a header-only C++ neural-network library for small CPU-side experiments. Its main workflow is to represent input and parameters with matrices or tensors, configure activations and losses, then train or run inference through an MLP; CNN training adds convolutional layers, flattens their output for the MLP classifier, and propagates gradients back. The graph separates numeric containers, reusable functions, layer implementations, and network orchestration. Relationships are based on the excerpts and README; the example is a demo, not a runtime dependency of the library.

Main entry points: [`lib_chest_nn.hpp`](https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/lib_chest_nn.hpp) (Public header), [`nn/network.hpp`](https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/network.hpp) (MLP workflow), [`nn/matrix.hpp`](https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/matrix.hpp) (Matrix operations), [`nn/activations.hpp`](https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/activations.hpp) (Activation functions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_containers["Numeric containers"]
  node_matrix["Matrix operations<br/>[matrix.hpp]"]
  node_tensor["Tensor operations<br/>[tensor_3d.hpp]"]
end

subgraph group_functions["Activations and losses"]
  node_activations["Activation functions<br/>[activations.hpp]"]
  node_losses["Loss functions<br/>[losses.hpp]"]
end

subgraph group_layers["Neural layers"]
  node_mlplayer["MLP layer<br/>[layer.hpp]"]
  node_cnnlayer["CNN layer<br/>[layer.hpp]"]
end

subgraph group_networks["Network workflows"]
  node_entry["Public header<br/>[lib_chest_nn.hpp]"]
  node_mlp["MLP workflow<br/>[network.hpp]"]
  node_cnn["CNN workflow<br/>[network.hpp]"]
  node_example["Usage demos<br/>[example.cpp]"]
end

node_developer(("Library user"))

node_developer -->|"includes"| node_entry
node_entry -->|"includes"| node_matrix
node_entry -->|"includes"| node_mlplayer
node_entry -->|"includes"| node_cnnlayer
node_entry -->|"includes"| node_activations
node_entry -->|"includes"| node_mlp
node_entry -->|"includes"| node_losses
node_entry -->|"includes"| node_tensor
node_activations -->|"operates on"| node_matrix
node_activations -->|"operates on"| node_tensor
node_losses -->|"operates on"| node_matrix
node_mlplayer -->|"computes with"| node_matrix
node_cnnlayer -->|"convolves with"| node_tensor
node_cnnlayer -->|"uses"| node_matrix
node_mlp -->|"dispatches"| node_mlplayer
node_mlp -->|"evaluates loss"| node_losses
node_mlp -->|"configures"| node_activations
node_mlp -->|"processes"| node_matrix
node_cnn -->|"dispatches"| node_cnnlayer
node_cnn -->|"trains classifier"| node_mlp
node_cnn -->|"flattens output"| node_tensor
node_example -->|"demonstrates"| node_entry
node_example -->|"trains"| node_cnn
node_example -->|"trains"| node_mlp

click node_entry "https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/lib_chest_nn.hpp"
click node_matrix "https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/matrix.hpp"
click node_tensor "https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/tensor_3d.hpp"
click node_activations "https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/activations.hpp"
click node_losses "https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/losses.hpp"
click node_mlplayer "https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/layer.hpp"
click node_cnnlayer "https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/layer.hpp"
click node_mlp "https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/network.hpp"
click node_cnn "https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/network.hpp"
click node_example "https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/example.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_matrix,node_tensor,node_developer toneBlue
class node_activations,node_losses toneAmber
class node_mlplayer,node_cnnlayer toneMint
class node_entry,node_mlp,node_cnn,node_example toneRose
```

## Components

### Numeric containers

- [Matrix operations](https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/matrix.hpp): `nn/matrix.hpp`
- [Tensor operations](https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/tensor_3d.hpp): `nn/tensor_3d.hpp`

### Activations and losses

- [Activation functions](https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/activations.hpp): `nn/activations.hpp`
- [Loss functions](https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/losses.hpp): `nn/losses.hpp`

### Neural layers

- [MLP layer](https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/layer.hpp): `nn/layer.hpp`
- [CNN layer](https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/layer.hpp): `nn/layer.hpp`

### Network workflows

- [Public header](https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/lib_chest_nn.hpp): `lib_chest_nn.hpp`
- [MLP workflow](https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/network.hpp): `nn/network.hpp`
- [CNN workflow](https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/nn/network.hpp): `nn/network.hpp`
- [Usage demos](https://github.com/nuistmrchest/libchestneuralnetwork/blob/main/example.cpp): `example.cpp`

### Other components

- **Library user**

## Connections

- Library user → Public header: includes (evidence: `README.md`)
- Public header → Matrix operations: includes (evidence: `lib_chest_nn.hpp`)
- Public header → MLP layer: includes (evidence: `lib_chest_nn.hpp`)
- Public header → CNN layer: includes (evidence: `lib_chest_nn.hpp`)
- Public header → Activation functions: includes (evidence: `lib_chest_nn.hpp`)
- Public header → MLP workflow: includes (evidence: `lib_chest_nn.hpp`)
- Public header → Loss functions: includes (evidence: `lib_chest_nn.hpp`)
- Public header → Tensor operations: includes (evidence: `lib_chest_nn.hpp`)
- Activation functions → Matrix operations: operates on (evidence: `nn/activations.hpp`)
- Activation functions → Tensor operations: operates on (evidence: `nn/activations.hpp`)
- Loss functions → Matrix operations: operates on (evidence: `nn/losses.hpp`)
- MLP layer → Matrix operations: computes with (evidence: `nn/layer.hpp`)
- CNN layer → Tensor operations: convolves with (evidence: `nn/layer.hpp`)
- CNN layer → Matrix operations: uses (evidence: `nn/layer.hpp`)
- MLP workflow → MLP layer: dispatches (evidence: `nn/network.hpp`)
- MLP workflow → Loss functions: evaluates loss (evidence: `nn/network.hpp`)
- MLP workflow → Activation functions: configures (evidence: `nn/network.hpp`)
- MLP workflow → Matrix operations: processes (evidence: `nn/network.hpp`)
- CNN workflow → CNN layer: dispatches (evidence: `nn/network.hpp`)
- CNN workflow → MLP workflow: trains classifier (evidence: `nn/network.hpp`)
- CNN workflow → Tensor operations: flattens output (evidence: `nn/network.hpp`)
- Usage demos → Public header: demonstrates (evidence: `example.cpp`)
- Usage demos → CNN workflow: trains (evidence: `example.cpp`)
- Usage demos → MLP workflow: trains (evidence: `example.cpp`)
