Skip to main content

Function: encodeMLPLayersBase64()

encodeMLPLayersBase64(layers): MLPBlock

Flattens an array of createMLP-shaped layers (see NeuralMLP.js - { inputSize, outputSize, activation, weights, biases }) into a single { dtype: 'float16', layout, dataBase64 } block: one dataBase64 blob holding every layer's weights immediately followed by its biases, in layer order (hidden1 -> hidden2 -> ... -> output), and a layout array describing how to slice that flat blob back apart - one { rows, cols, kind: 'weight' } entry (rows === inputSize, cols === outputSize, weights.length === rows * cols) immediately followed by one { rows: 1, cols: outputSize, kind: 'bias' } entry, per layer. activation is carried on the weight entry (not a separate parallel array) purely for convenience/robustness on the decode side - every neural-* trainer's createMLP calls already fix a hiddenActivation/outputActivation pair (see NeuralTextureModel.js/NeuralAppearanceModel.js), so decoders could in principle re-derive it from layer position alone, but storing it removes that assumption. Shared by NeuralTextureManifest.js and NeuralAppearanceManifest.js so a decoder MLP's layer layout is encoded identically in both .neuralTexture/.neuralMaterial and .neuralAppearance manifests.

Parameters​

layers​

MLPLayer[]

Returns​

MLPBlock