# kashkovvv/neural_network architecture

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

- Interactive diagram: https://gitdiagram.com/kashkovvv/neural_network
- Repository: https://github.com/kashkovvv/neural_network

## Overview

This is a header-only C++ neural-network math library. Its implemented workflow is to create and manipulate tensors, pass them through a linear layer and activation functions, then compare predictions with a loss; these are independent building blocks, not an assembled network. Tensor views provide slice-based access, while indexing, concepts, and compensated accumulation support the core implementation. The README describes training, autograd, data pipelines, and additional models as future work, not current capabilities. Edges reflect shown includes, calls, or documented behavior; unsampled implementation details are not inferred.

Main entry points: [`include/nn/tensor.hpp`](https://github.com/kashkovvv/neural_network/blob/main/include/nn/tensor.hpp) (Tensor operations), [`include/nn/tensor_view.hpp`](https://github.com/kashkovvv/neural_network/blob/main/include/nn/tensor_view.hpp) (Tensor views), [`include/nn/linear.hpp`](https://github.com/kashkovvv/neural_network/blob/main/include/nn/linear.hpp) (Linear layer), [`include/nn/losses.hpp`](https://github.com/kashkovvv/neural_network/blob/main/include/nn/losses.hpp) (Loss functions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_tensor_core["Tensor core"]
  node_tensor["Tensor operations<br/>[tensor.hpp]"]
  node_tensor_view["Tensor views<br/>[tensor_view.hpp]"]
end

subgraph group_nn_components["Network components"]
  node_linear["Linear layer<br/>[linear.hpp]"]
  node_activations["Activations<br/>[activations.hpp]"]
  node_losses["Loss functions<br/>[losses.hpp]"]
end

subgraph group_implementation_support["Implementation support"]
  node_indexing["Tensor indexing"]
  node_concepts["Type constraints"]
  node_accumulator["Stable accumulation"]
end

node_user(("Library user"))

node_user -->|"creates and operates"| node_tensor
node_user -->|"applies layer"| node_linear
node_user -->|"applies activation"| node_activations
node_user -->|"evaluates loss"| node_losses
node_tensor -->|"creates views"| node_tensor_view
node_tensor -->|"uses indexing"| node_indexing
node_tensor -->|"constrains elements"| node_concepts
node_tensor -->|"accumulates reductions"| node_accumulator
node_tensor_view -->|"uses indexing"| node_indexing
node_tensor_view -->|"constrains elements"| node_concepts
node_linear -->|"computes matmul"| node_tensor
node_linear -->|"constrains elements"| node_concepts
node_activations -->|"transforms tensors"| node_tensor
node_losses -->|"reads and returns tensors"| node_tensor
node_losses -->|"accumulates loss"| node_accumulator

click node_tensor "https://github.com/kashkovvv/neural_network/blob/main/include/nn/tensor.hpp"
click node_tensor_view "https://github.com/kashkovvv/neural_network/blob/main/include/nn/tensor_view.hpp"
click node_linear "https://github.com/kashkovvv/neural_network/blob/main/include/nn/linear.hpp"
click node_activations "https://github.com/kashkovvv/neural_network/blob/main/include/nn/activations.hpp"
click node_losses "https://github.com/kashkovvv/neural_network/blob/main/include/nn/losses.hpp"
click node_indexing "https://github.com/kashkovvv/neural_network/blob/main/include/nn/detail/tensor_indexing.hpp"
click node_concepts "https://github.com/kashkovvv/neural_network/blob/main/include/nn/detail/tensor_concepts.hpp"
click node_accumulator "https://github.com/kashkovvv/neural_network/blob/main/include/nn/detail/compensated_accumulator.hpp"

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_tensor,node_tensor_view,node_user toneBlue
class node_linear,node_activations,node_losses toneAmber
class node_indexing,node_concepts,node_accumulator toneMint
```

## Components

### Tensor core

- [Tensor operations](https://github.com/kashkovvv/neural_network/blob/main/include/nn/tensor.hpp): `include/nn/tensor.hpp`
- [Tensor views](https://github.com/kashkovvv/neural_network/blob/main/include/nn/tensor_view.hpp): `include/nn/tensor_view.hpp`

### Network components

- [Linear layer](https://github.com/kashkovvv/neural_network/blob/main/include/nn/linear.hpp): `include/nn/linear.hpp`
- [Activations](https://github.com/kashkovvv/neural_network/blob/main/include/nn/activations.hpp): `include/nn/activations.hpp`
- [Loss functions](https://github.com/kashkovvv/neural_network/blob/main/include/nn/losses.hpp): `include/nn/losses.hpp`

### Implementation support

- [Tensor indexing](https://github.com/kashkovvv/neural_network/blob/main/include/nn/detail/tensor_indexing.hpp): `include/nn/detail/tensor_indexing.hpp`
- [Type constraints](https://github.com/kashkovvv/neural_network/blob/main/include/nn/detail/tensor_concepts.hpp): `include/nn/detail/tensor_concepts.hpp`
- [Stable accumulation](https://github.com/kashkovvv/neural_network/blob/main/include/nn/detail/compensated_accumulator.hpp): `include/nn/detail/compensated_accumulator.hpp`

### Other components

- **Library user**

## Connections

- Library user → Tensor operations: creates and operates (evidence: `README.md`)
- Library user → Linear layer: applies layer (evidence: `README.md`)
- Library user → Activations: applies activation (evidence: `README.md`)
- Library user → Loss functions: evaluates loss (evidence: `README.md`)
- Tensor operations → Tensor views: creates views (evidence: `include/nn/tensor.hpp`)
- Tensor operations → Tensor indexing: uses indexing (evidence: `include/nn/tensor.hpp`)
- Tensor operations → Type constraints: constrains elements (evidence: `include/nn/tensor.hpp`)
- Tensor operations → Stable accumulation: accumulates reductions (evidence: `include/nn/tensor.hpp`)
- Tensor views → Tensor indexing: uses indexing (evidence: `include/nn/tensor_view.hpp`)
- Tensor views → Type constraints: constrains elements (evidence: `include/nn/tensor_view.hpp`)
- Linear layer → Tensor operations: computes matmul (evidence: `include/nn/linear.hpp`)
- Linear layer → Type constraints: constrains elements (evidence: `include/nn/linear.hpp`)
- Activations → Tensor operations: transforms tensors (evidence: `include/nn/activations.hpp`)
- Loss functions → Tensor operations: reads and returns tensors (evidence: `include/nn/losses.hpp`)
- Loss functions → Stable accumulation: accumulates loss (evidence: `include/nn/losses.hpp`)
