The operator's call: "there should be one default learning rate and one
default max iterations and they should both be configurable at runtime."
There were SIX copies, not the four the audit described, and they did not
agree:
nisps/ml/mlp.hpp no-arg train() hardcoding 1.f / 1000u / 0.001f —
and firmware's ONLY training path calls exactly
this, so firmware had no runtime knob at all
wasm-iml.ts train() and trainAsync() TS default params (x2)
engine-api.ts learningRate ?? 1.0, with no maxIterations knob
vcv/src/iml.hpp 200 / 0.1 / 0.00001 — silently divergent
external_synth_midi.hpp its own kDefaultLearningRate/kDefaultMaxIterations
schemas/modes/*.json x9, identical, read by nobody at runtime
Now: schemas/ml_defaults.json is the single declaration (validated against a
sibling meta-schema, matching the midi_device.schema.json convention), codegen
emits it to C++ and TS in the same run, and MLPCore carries a TrainConfig whose
default member initialisers read the generated constant.
set_train_config()/nisps_ml_set_train_config() make it runtime-overridable on
every target; the explicit-argument train() overload is untouched. min_error
joins the tuple — it was duplicated identically and belongs with the other two.
The per-mode ml block loses default_learning_rate/default_max_iterations.
default_spread stays (genuinely wired on both targets) and input_channels stays
(codegen-time validated, real information for sound_analysis_midi).
VCV BEHAVIOUR CHANGE, deliberate: MEMLNaut.cpp constructs IML positionally and
relies on those defaults, so the module moves to 1000/1.0/0.001 — 5x the max
iterations, 10x the learning rate, and a 100x looser early-stop threshold. The
old values were never justified anywhere; they arrived with fbc68eb alongside
an unrelated module rewrite and no tuning rationale. Firmware and WASM have
shipped 1.0/1000 all along. It is now runtime-settable if this turns out worse.
The generated header lands in nisps/ml/generated/, not nisps/modes/generated/
where the rest of codegen output lives: training hyperparameters are an ML
fact, and nisps/ml sits below nisps/modes, so emitting them there would make
mlp.hpp include upward. The agent that built this flagged the directory-crossing
rather than hiding it; this is the fix. CI's generated-freshness gate learns the
new directory.
Gates: run-all-tests.sh ALL GREEN — 4/4 ctest, parity PASS (max delta 2.38e-7),
lint clean, manifold typecheck + 17 unit + 33 e2e (which exercise train() and
trainAsync() through a real browser).
107 lines
3.6 KiB
JSON
107 lines
3.6 KiB
JSON
{
|
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
"$id": "https://memlnaut/schemas/mode.schema.json",
|
|
"title": "MEMLNaut Mode Schema",
|
|
"description": "Meta-schema for one MEMLNaut mode: parameter contract, ML config, and UI hints. The schemas/modes/*.json files it validates are the canonical contract — codegen/generate.ts emits the C++ headers (nisps/modes/generated/) and TypeScript modules (manifold/src/modes/generated/) from them. Provenance notes and judgement calls live in schemas/modes/params_notes.md.",
|
|
"type": "object",
|
|
"required": [
|
|
"mode_id",
|
|
"engine_id",
|
|
"ml",
|
|
"params",
|
|
"voice_spaces",
|
|
"ui"
|
|
],
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"$schema": { "type": "string" },
|
|
"_note": {
|
|
"type": "string",
|
|
"description": "Free-text note from the schema author (e.g. about ranges that were guessed)."
|
|
},
|
|
"mode_id": {
|
|
"type": "string",
|
|
"pattern": "^[a-z][a-z0-9_]*$",
|
|
"description": "snake_case identifier for the mode. Must be unique."
|
|
},
|
|
"engine_id": {
|
|
"type": "string",
|
|
"pattern": "^[a-z][a-z0-9_]*$",
|
|
"description": "snake_case identifier for the audio engine the mode uses."
|
|
},
|
|
"ml": {
|
|
"type": "object",
|
|
"required": [
|
|
"input_channels",
|
|
"input_size",
|
|
"hidden_layers",
|
|
"output_size",
|
|
"default_spread"
|
|
],
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"input_channels": {
|
|
"type": "array",
|
|
"items": {
|
|
"type": "string",
|
|
"pattern": "^[a-z][a-z0-9_]*$"
|
|
},
|
|
"minItems": 1,
|
|
"description": "Names of abstract input channels (e.g. joy_x, midi_velocity, audio_pitch)."
|
|
},
|
|
"input_size": { "type": "integer", "minimum": 1 },
|
|
"hidden_layers": {
|
|
"type": "array",
|
|
"items": { "type": "integer", "minimum": 1 },
|
|
"minItems": 1
|
|
},
|
|
"output_size": { "type": "integer", "minimum": 1 },
|
|
"default_spread": { "type": "number", "minimum": 0.0, "maximum": 1.0 }
|
|
}
|
|
},
|
|
"params": {
|
|
"type": "array",
|
|
"minItems": 1,
|
|
"items": {
|
|
"type": "object",
|
|
"required": ["name", "label", "min", "max", "default", "curve", "group"],
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"name": {
|
|
"type": "string",
|
|
"pattern": "^[a-z][a-z0-9_]*$",
|
|
"description": "snake_case identifier; unique within this mode."
|
|
},
|
|
"label": { "type": "string" },
|
|
"min": { "type": "number" },
|
|
"max": { "type": "number" },
|
|
"default": { "type": "number" },
|
|
"curve": {
|
|
"type": "string",
|
|
"enum": ["linear", "exp", "log", "square", "sqrt", "sigmoid", "cubic"]
|
|
},
|
|
"group": { "type": "string" },
|
|
"_note": { "type": "string" }
|
|
}
|
|
}
|
|
},
|
|
"voice_spaces": {
|
|
"type": "array",
|
|
"items": { "type": "string" },
|
|
"description": "Names of C++ voice space lambdas the mode supports. May be empty for engines with no voice spaces (e.g. sequencers)."
|
|
},
|
|
"ui": {
|
|
"type": "object",
|
|
"required": ["primary_input", "show_voice_space_selector", "show_synth_visualizer"],
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"primary_input": {
|
|
"type": "string",
|
|
"enum": ["xy_pad", "joystick", "sliders", "audio_in", "midi_in", "none"]
|
|
},
|
|
"show_voice_space_selector": { "type": "boolean" },
|
|
"show_synth_visualizer": { "type": "boolean" }
|
|
}
|
|
}
|
|
}
|
|
}
|