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

Construction Functions.
http://tituxdev.github.io/NeuroTIC/src/CPU/ntbuilder.c. More...

#include "ntcore.h"
#include <stddef.h>
Include dependency graph for ntbuilder.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NEWNET(network, neurons)   newnet( &network, neurons, (layer_t)sizeof( neurons )/sizeof( uint16_t ) )
 Convenience macro to create a new network.
 
#define CREATE_NET_FEEDFORWARD(network, i, neurons)
 Convenience macro to create and build a feedforward network.
 

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

Construction Functions.
http://tituxdev.github.io/NeuroTIC/src/CPU/ntbuilder.c.

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.h.

Macro Definition Documentation

◆ CREATE_NET_FEEDFORWARD

#define CREATE_NET_FEEDFORWARD (   network,
  i,
  neurons 
)
Value:
net_s network={ \
.inputs= i, \
.layers= sizeof( neurons )/sizeof( uint16_t ), \
}; \
buildnet( newfeedforward( NEWNET( network , neurons ) ) );
#define NEWNET(network, neurons)
Convenience macro to create a new network.
Definition ntbuilder.h:25
struct net_s * newfeedforward(net_s *net)
Initializes a simple feedforward topology.
Definition ntfeedforward.c:21
Root structural container of a NeuroTIC network.
Definition ntcore.h:100
input_t inputs
Definition ntcore.h:101

Convenience macro to create and build a feedforward network.

Combines newnet() and buildnet() into a single step for creating a feedforward network with the specified input size and layer configuration.

Parameters
networkName of the network variable to create.
iNumber of external inputs to the network.
neuronsArray defining the number of neurons in each layer.
Returns
net_s Pointer to the fully constructed feedforward network.

◆ NEWNET

#define NEWNET (   network,
  neurons 
)    newnet( &network, neurons, (layer_t)sizeof( neurons )/sizeof( uint16_t ) )

Convenience macro to create a new network.

Simplifies calling newnet() by automatically calculating the number of layers from the neurons array size.

Parameters
networkPointer to the network structure to initialize.
neuronsArray defining the number of neurons per layer.
Returns
net_s Pointer to the initialized network on success, or NULL on failure.

Function Documentation

◆ buildnet()

struct net_s * buildnet ( net_s net)

Builds the internal buffers and connections of a neural network.

Parameters
netPointer to the network structure to build.
Returns
Pointer to the fully constructed 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.

Parameters
netPointer to the network structure to initialize.
neurons_per_layerArray specifying the number of neurons in each layer.
layers_sizeNumber of layers (size of neurons_per_layer array).
Returns
Pointer to the initialized network on success, or NULL on failure.

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().