RBF Layer — Machine Learning/Neural Networks
Machine_Learning/Neural_Networks/RBF_Layer · 1 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text
Description#
The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.
RBF Layer
Machine Learning / Neural Networks
A radial basis function network with its fitted parameters baked in: each centre answers φᵢ = exp(−‖u − cᵢ‖² / (2σᵢ²)), and the readout is yₖ = Σᵢ Wₖᵢ·φᵢ + bₖ.
The network engineers reach for when they have to defend the model: a centre only responds near its own neighbourhood, so what the network does in one region of the input space cannot be moved by a centre fitted to another – and every parameter is a place, a width or a weight rather than an uninterpretable coefficient. It is also the one model here whose parameters can be fitted with no framework at all: k-means for the centres, least squares for the readout.
Ports
- u – the feature column, [m,1], where m is the NUMBER OF COLUMNS of Centres. A different size stops the run rather than broadcasting.
- Output – y, a column [p,1], where p is the NUMBER OF ROWS of Output Weights. With one row this is the plain scalar RBF network.
Parameters
- Centres – [N,m], one centre per ROW. That is k-means' orientation and the one K Means Assign uses in this library, so a fitted set pastes into either block unchanged. Its shape sets both the number of centres and the required input width.
- Widths – σ, either one per centre ([N,1]) or a single scalar shared by all of them. Every value must be > 0. A width is a DISTANCE in the same units as the input, so it scales with the features rather than with the output.
- Output Weights – [p,N], the linear readout: one row per output, one column per centre. Its row count is the output height.
- Bias – [p,1], added after the readout. This is what the network returns far away from every centre, where all φ have decayed to zero – so it is the model's default answer, not a cosmetic offset.
- Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.
Code export
All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. Every parameter is structural and baked into the body; there is no tunable parameter, and the network is fully unrolled, so no backend contains a loop or an index computed at run time.
The widths are folded once, at config load, into 1/(2σ²) – so the emitted body multiplies where the formula divides, and no target carries a division per centre per sample.
The three HDL targets are simulation-only real
arithmetic, quantizing only at the port boundary, because a Gaussian needs
exp and that does not belong in a Q16.16 datapath. They simulate
correctly and are not offered for synthesis – the same choice
Dense Layer makes for its Tanh and Sigmoid activations. PLC
Structured Text needs no such caveat: EXP is part of IEC
61131-3.
Simulink bridge
None. Simulink's Deep Learning blocks take a trained network
object, which no parameter mapping can carry, and there is no RBF block in
the base product to map onto. The bridge reports the block rather than
dropping it silently, and it has no parity testbench, which is the
documented consequence of Support::None rather than a gap.
Notes
- Algebraic and stateless: the output depends only on the current input, so the block cannot break an algebraic loop.
- Nonlinear, and deliberately carries no state space – the Gaussian is not a linear form and a fabricated one would let model reduction merge away exactly the nonlinearity the block exists for.
- It cannot overflow. The exponent argument is
−‖u − c‖²·(1/(2σ²)), which is
never positive, so
expis only ever evaluated on [−∞, 0] and saturates to zero rather than to infinity. Far from every centre the block returns its Bias, which is the honest answer for a local model asked about a place it was never fitted on. - The squared distance is used as-is – there is no square root anywhere, because the exponent takes the squared distance directly.
Code facts#
| Fact | Value |
|---|---|
| registered type | Machine_Learning/Neural_Networks/RBF_Layer |
| family | Machine_Learning/Neural_Networks |
| solver environment class | ICoreBlock_0_Machine_Learning_1_Neural_Networks_2_RBF_Layer |
| source | src/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Neural_Networks/RBF_Layer/ICoreBlock_0_Machine_Learning_1_Neural_Networks_2_RBF_Layer.cpp |
| header | src/ICoreSDK/ICoreBlockLibrary/Blocks/Machine_Learning/Neural_Networks/RBF_Layer/ICoreBlock_0_Machine_Learning_1_Neural_Networks_2_RBF_Layer.h |
| default size on canvas | 126 × 84 px |
| ports at insert | 1 in, 1 out |
| code generators implemented | Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text |
Ports#
| # | Direction | Signal type | Description label |
|---|---|---|---|
| 1 | in | ICoreDouble | u |
| 2 | out | ICoreDouble | y |
Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.
Configuration variables#
| Config variable | Default | Simulink parameter |
|---|---|---|
Centres | [-0.8 0.5; 0.2 -0.4; 1.1 0.9] | — |
Widths | [0.7; 1.1; 0.9] | — |
Output Weights | [1.2 -0.8 0.45] | — |
Bias | 0.3 | — |
Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.
Simulink bridge#
| support | Support::None |
| Simulink path | — |
| port-count rule | PortsParam::None |
SampleTime parameter | yes |
Caveat (shown to the user): no Simulink equivalent: the base product has no radial basis function block, and the Deep Learning blocks take a trained network OBJECT rather than the centres, widths and readout weights this block carries as ordinary matrices
Catalog contract: src/ICoreSDK/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h
Description vs code#
The checker has a blind spot here — it could not resolve something (a grouped port bullet, a computed config name), which is reported and never counted as a pass. A reader has to settle it:
B0every stimulus in the sample errored — cross-checks skipped
The verdict above is
tools/docs/check_block_descriptions.py(P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.
File banner (developer view)#
The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).
RBF Layer — a radial basis function network with its weights baked in phi_i = exp(-||u - c_i||^2 / (2*sigma_i^2)) y_k = SUM_i W_ki * phi_i + b_k
See the header for the four properties that decide how this is emitted: the widths are folded once into 1/(2*sigma^2), the exponent argument can never be positive, the squared distance needs no sqrt, and the exp is what puts the three HDL targets into simulation-only
realarithmetic (the escape hatch Dense_Layer's Tanh and Sigmoid established for this family, and Recursive IIR before it).
Sample results#
No stimulus produced a sampled output in this rig — Invalid input size at: ICore Blocks/Home/RBF Layer. That is a fact about the single-block rig, not a verdict on the block: an offline batch fit, a block whose output only appears at onSolverFinish, or one that needs a driven environment cannot be exercised alone.
Category unsampled · sample time 0.1 · 60 steps · commit ccf005c8 · produced by docsSample --out <folder> --steps 60
Sample data: docs/generated/samples/Machine_Learning__Neural_Networks__RBF_Layer.json