|
FlexNN 1
Fully connected neural network built from scratch with flexible n-layer design and multiple activations.
|
Implements FlexNN flat binary export/import per LLD_FLEXNN §7. More...
#include "ModelIO.hpp"#include <algorithm>#include <array>#include <cassert>#include <cstdint>#include <cstring>#include <fstream>#include <vector>#include "layers/Layer.hpp"#include "activations/Activation.hpp"
Classes | |
| struct | FlexNN::MainHeader |
| struct | FlexNN::LayerHeader |
Namespaces | |
| namespace | FlexNN |
| Namespace for the FlexNN neural network library. | |
Functions | |
| Status | FlexNN::exportModel (const NeuralNetwork &net, const std::string &path, ExportOptions opts={}) |
Export a trained NeuralNetwork to flat binary model.bin. | |
| Status | FlexNN::importModel (NeuralNetwork &net, const std::string &path) |
Import a flat binary model.bin into a NeuralNetwork. | |
Implements FlexNN flat binary export/import per LLD_FLEXNN §7.
Why this file exists: FlexNN is the source of truth for training; any runtime (including TinyForge) consumes model.bin without Eigen. The writer is intentionally small (no JSON/Protobuf) and deterministic (little-endian, IEEE floats, CRC).
Layout (all LE, packed, no padding): Main header 20B: magic 0x54464E47, version 1, header_len 20, layer_count, flags 0, header_crc32 (CRC of first 16B) Per-layer 52B: type, act, dtype, in_dim, out_dim, w_cnt, b_cnt, aux_cnt, reserved, w_off, b_off, aux_off, c_in, c_out, k, stride, pad, dilation Blobs: w (float32), b (float32), aux (float32) at absolute offsets Footer: file_crc32 (CRC of whole file except last 4B)