# libfann/fann architecture

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

- Interactive diagram: https://gitdiagram.com/libfann/fann
- Repository: https://github.com/libfann/fann

## Overview

FANN is a C neural-network library for constructing, training, running, and saving multilayer networks, with float, double, and fixed-point variants. Its principal workflow is to create a network, train it using training data, then run it for inference; Cascade2 adds topology growth, while persistence, C++ wrappers, and parallel variants extend usage. The tree also contains vendored Google Test/Mock, but it is test infrastructure rather than part of FANN’s runtime product. Relationships beyond README-described capabilities are omitted because implementation excerpts are limited.

Main entry points: [`src/include/fann.h`](https://github.com/libfann/fann/blob/master/src/include/fann.h) (Network API), [`src/fann_io.c`](https://github.com/libfann/fann/blob/master/src/fann_io.c) (Save and Load), [`src/include/fann_train.h`](https://github.com/libfann/fann/blob/master/src/include/fann_train.h) (Training API), [`src/fann_train_data.c`](https://github.com/libfann/fann/blob/master/src/fann_train_data.c) (Training Data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_network["Network Runtime"]
  node_network_api["Network API<br/>[fann.h]"]
  node_network_core["Network Core<br/>[fann.c]"]
  node_network_state["Network State<br/>[fann_data.h]"]
  node_activations["Activation Functions<br/>[fann_activation.h]"]
  node_persistence["Save and Load<br/>[fann_io.c]"]
  node_error_handling["Error Handling<br/>[fann_error.c]"]
end

subgraph group_learning["Training"]
  node_training_api["Training API<br/>[fann_train.h]"]
  node_training_engine["Training Engine<br/>[fann_train.c]"]
  node_training_data["Training Data<br/>[fann_train_data.c]"]
  node_cascade["Cascade Training<br/>[fann_cascade.c]"]
end

subgraph group_interfaces["Interfaces"]
  node_cpp_api["C++ Wrappers<br/>[fann_cpp.h]"]
  node_cpp_training_data["C++ Data Wrappers"]
  node_parallel_c["Parallel C<br/>[parallel_fann.c]"]
  node_parallel_cpp["Parallel C++"]
end

subgraph group_execution["Numeric Execution"]
  node_float_variant["Float Variant<br/>[floatfann.c]"]
  node_double_variant["Double Variant<br/>[doublefann.c]"]
  node_fixed_variant["Fixed Variant<br/>[fixedfann.c]"]
end

node_user(("Library User"))

node_user -->|"creates network"| node_network_api
node_user -->|"trains network"| node_training_api
node_user -->|"runs inference"| node_network_api
node_user -->|"supplies training data"| node_training_data
node_user -->|"evolves topology"| node_cascade
node_user -->|"saves or loads"| node_persistence
node_user -->|"selects numeric mode"| node_float_variant
node_user -->|"selects numeric mode"| node_double_variant
node_user -->|"selects numeric mode"| node_fixed_variant

click node_network_api "https://github.com/libfann/fann/blob/master/src/include/fann.h"
click node_network_core "https://github.com/libfann/fann/blob/master/src/fann.c"
click node_network_state "https://github.com/libfann/fann/blob/master/src/include/fann_data.h"
click node_activations "https://github.com/libfann/fann/blob/master/src/include/fann_activation.h"
click node_persistence "https://github.com/libfann/fann/blob/master/src/fann_io.c"
click node_error_handling "https://github.com/libfann/fann/blob/master/src/fann_error.c"
click node_training_api "https://github.com/libfann/fann/blob/master/src/include/fann_train.h"
click node_training_engine "https://github.com/libfann/fann/blob/master/src/fann_train.c"
click node_training_data "https://github.com/libfann/fann/blob/master/src/fann_train_data.c"
click node_cascade "https://github.com/libfann/fann/blob/master/src/fann_cascade.c"
click node_cpp_api "https://github.com/libfann/fann/blob/master/src/include/fann_cpp.h"
click node_cpp_training_data "https://github.com/libfann/fann/blob/master/src/include/fann_training_data_cpp.h"
click node_parallel_c "https://github.com/libfann/fann/blob/master/src/parallel_fann.c"
click node_parallel_cpp "https://github.com/libfann/fann/blob/master/src/parallel_fann_cpp.cpp"
click node_float_variant "https://github.com/libfann/fann/blob/master/src/floatfann.c"
click node_double_variant "https://github.com/libfann/fann/blob/master/src/doublefann.c"
click node_fixed_variant "https://github.com/libfann/fann/blob/master/src/fixedfann.c"

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_network_api,node_network_core,node_network_state,node_activations,node_persistence,node_error_handling,node_user toneBlue
class node_training_api,node_training_engine,node_training_data,node_cascade toneAmber
class node_cpp_api,node_cpp_training_data,node_parallel_c,node_parallel_cpp toneMint
class node_float_variant,node_double_variant,node_fixed_variant toneRose
```

## Components

### Network Runtime

- [Network API](https://github.com/libfann/fann/blob/master/src/include/fann.h): `src/include/fann.h`
- [Network Core](https://github.com/libfann/fann/blob/master/src/fann.c): `src/fann.c`
- [Network State](https://github.com/libfann/fann/blob/master/src/include/fann_data.h): `src/include/fann_data.h`
- [Activation Functions](https://github.com/libfann/fann/blob/master/src/include/fann_activation.h): `src/include/fann_activation.h`
- [Save and Load](https://github.com/libfann/fann/blob/master/src/fann_io.c): `src/fann_io.c`
- [Error Handling](https://github.com/libfann/fann/blob/master/src/fann_error.c): `src/fann_error.c`

### Training

- [Training API](https://github.com/libfann/fann/blob/master/src/include/fann_train.h): `src/include/fann_train.h`
- [Training Engine](https://github.com/libfann/fann/blob/master/src/fann_train.c): `src/fann_train.c`
- [Training Data](https://github.com/libfann/fann/blob/master/src/fann_train_data.c): `src/fann_train_data.c`
- [Cascade Training](https://github.com/libfann/fann/blob/master/src/fann_cascade.c): `src/fann_cascade.c`

### Interfaces

- [C++ Wrappers](https://github.com/libfann/fann/blob/master/src/include/fann_cpp.h): `src/include/fann_cpp.h`
- [C++ Data Wrappers](https://github.com/libfann/fann/blob/master/src/include/fann_training_data_cpp.h): `src/include/fann_training_data_cpp.h`
- [Parallel C](https://github.com/libfann/fann/blob/master/src/parallel_fann.c): `src/parallel_fann.c`
- [Parallel C++](https://github.com/libfann/fann/blob/master/src/parallel_fann_cpp.cpp): `src/parallel_fann_cpp.cpp`

### Numeric Execution

- [Float Variant](https://github.com/libfann/fann/blob/master/src/floatfann.c): `src/floatfann.c`
- [Double Variant](https://github.com/libfann/fann/blob/master/src/doublefann.c): `src/doublefann.c`
- [Fixed Variant](https://github.com/libfann/fann/blob/master/src/fixedfann.c): `src/fixedfann.c`

### Other components

- **Library User**

## Connections

- Library User → Network API: creates network
- Library User → Training API: trains network
- Library User → Network API: runs inference
- Library User → Training Data: supplies training data
- Library User → Cascade Training: evolves topology
- Library User → Save and Load: saves or loads
- Library User → Float Variant: selects numeric mode
- Library User → Double Variant: selects numeric mode
- Library User → Fixed Variant: selects numeric mode
