NeuroTIC 0.0
Loading...
Searching...
No Matches
ntbuilder.c File Reference

Implementation of network construction functions. More...

#include "ntbuilder.h"
#include "ntmemory.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Include dependency graph for ntbuilder.c:

Go to the source code of this file.

Functions

struct net_snewnet (net_s *net, uint16_t *neurons_per_layer, layer_t layers_size)
 Initializes a new neural network structure.
 
struct net_sbuildnet (net_s *net)
 Builds the internal buffers and connections of a neural network.
 

Detailed Description

Implementation of network construction functions.

Provides memory allocation and pointer setup for neurons, input/output references, and inter-layer buffers.
Uses memtrack() to manage memory safely.

Author
Oscar Sotomayor
Date
2026

Definition in file ntbuilder.c.

Function Documentation

◆ buildnet()

struct net_s * buildnet ( net_s net)

Builds the internal buffers and connections of a neural network.

Allocates memory for inputs, outputs, and inter-layer buffers according to the bff_wiring configuration.
Sets neuron input pointers and weight arrays.
Buffer type explanations:

  • 'M': Mixed buffer; each pointer is set based on src_type.
    • 'N': Points to another buffer in the network.
    • 'I': Points to the network input array.
    • 'O': Points to the network output array.
  • 'N': Shared network buffer.
  • 'I': Network input array.
  • 'O': Network output array.

Validates wiring configurations and ensures all pointers are correctly set up for feedforward computation. Uses memtrack for all allocations.

References wiring_s::array_type, wiring_s::arrays, net_s::bff, neuron_s::bff_idx, neuron_s::in, net_s::in, neuron_s::inputs, net_s::inputs, net_s::layers, net_s::neurons, net_s::nn, neuron_s::out, net_s::out, wiring_s::size, wiring_s::src_index, wiring_s::src_layer, wiring_s::src_type, and net_s::wiring.

Referenced by loadnet().

◆ newnet()

struct net_s * newnet ( net_s net,
uint16_t *  neurons_per_layer,
layer_t  layers_size 
)

Initializes a new neural network structure.

Initializes a new neural network structure by allocating memory for neurons and layers, and setting initial pointers to NULL.
Validates input parameters and uses memtrack to register allocations for automatic cleanup.

References net_s::layers, and net_s::neurons.

Referenced by loadnet().