Expand description
A multilayer perceptron with one hidden layer, ported from the
NeuralNetwork / MultilayerPerceptron path of tinymind (C++) cpp/neuralnet.hpp,
in two forms: MultilayerPerceptron trains on the device, and
InferencePerceptron only runs a trained network (C++ IsTrainable = false).
The C++ network is assembled from layer, neuron, connection, gradient-manager
and training-policy templates, stored in placement-new byte buffers. This port
keeps only what the default MLP configuration actually executes
(FixedPointTransferFunctions with default policies, or tinymind (C++)’s
floating-point bundle for f32/f64, plus optional
GradientClipByValue, an optional Adam or RMSprop optimizer, and optional L2
weight decay and a step-decay learning-rate schedule (crate::training,
wrapping the optimizer); batch size 1, no recurrence, one hidden layer; for more
hidden layers see NeuralNetwork) and stores everything
in plain fixed-size arrays:
no heap, so the crate stays #![no_std].
Every arithmetic step keeps the C++ operation order, because fixed-point multiplication truncates and a reordered expression gives different bits.
To pick a class, rank the output logits with predicted_class()
(output_pre_activations() returns them) rather than learned_values():
the fixed-point sigmoid table is flat beyond ±6, so confident outputs tie.
Structs§
- Inference
Perceptron - An inference-only multilayer perceptron:
INinputs ->HIDhidden neurons (activationH) ->OUToutputs (activationO), holding only its weights. - Multilayer
Perceptron INinputs ->HIDhidden neurons (activationH) ->OUToutputs (activationO).