feat(examples): kws_raw raw-waveform + in-model downsample parity demo (Stage 3 PR-B)#256
Merged
Conversation
…ence The raw model at the spec lr=0.001/15ep never escapes random init (flat loss, all-class-0 predictions) → a degenerate bit-parity gate. Add a rate-agnostic LayerNorm(64) on the pooled features before fc and tune to lr=0.005 / 20 epochs: the model now reaches test_acc 0.588 with predictions spread across all 6 classes, making the AvgPool[1,16000] §11.3 bit-parity proof meaningful (C reproduces the diverse PyTorch predictions exactly: 2483/2483 int32-identical). LayerNorm is the framework's only bit-parity-covered normalizer (BatchNorm is not), so the gate is preserved. C model: MODEL_SIZE 14->15, layerNormLayerInit at model[12] (normalizedShape=[64], eps 1e-5 = PyTorch default), 5-entry state-dict (+ln gamma/beta), +LayerNormApi/LayerNorm link libs. kws_mfcc (shipped) is unchanged.
This was referenced Jun 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
examples/kws_raw/— SpeechCommands keyword spotting on the raw 16 kHz waveform with in-model downsampling. Completes Stage 3 of the 1D-CNN example suite (PR-B; reuses the shared loader from PR-A #255).Model:
AvgPool1d(K=16,S=16)(16 kHz→1 kHz decimation) → 3×Conv1d(K3,SAME)+ReLU+MaxPool(4)→AdaptiveAvgPool1d(1)→LayerNorm(64)→Linear. Lengths 16000→1000→250→62→15→1.Gate:
BIT_PARITY=1C int32 predictions bit-identical to PyTorch (2483/2483), diverse across all 6 classes — a real §11.3 proof thatAvgPool1dover[1,16000], the Conv chain, and the CLayerNormall reproduce PyTorch bit-for-bit. First example/integration exercise of the framework's LayerNorm.Convergence note: raw waveforms don't train at the MFCC settings (lr=0.001/15ep → the reference collapses to one class, which would make the gate degenerate). Fixed with a rate-agnostic
LayerNorm(64)(the framework's only bit-parity-covered normalizer; BatchNorm is not) + lr=0.005 / 20 epochs → test_acc 0.588 with predictions across all 6 classes. kws_mfcc is unchanged.CI: per-example processed-
.npycache (gates prepare on cache-hit) + shared raw-download cache (from PR-A); int32-exact diff; 6-class only (35-class is local-only, compiled by the build-all rot guard).🤖 Generated with Claude Code