/ proof-of-concept / steelsim31
Sign in
proof-of-concept / steelsim31
steelsim31 / ml / README.md
24 lines · 2.9 KBPreviewCodeBlameHistoryRaw
1# Predicting the sheet parameters from the sound
3`ml/` holds a first inverse model: a convolutional network that maps the spectrogram of a single strike to the logarithms of E, rho, h, Lx, and Ly. It is trained on the clips of `scripts/generate.ts` (see `scripts/README-dataset.md`) and meant to be retrained as the clips accumulate, so that the error can be followed against the size of the dataset.
5 python3 ml/train.py --data DATASET_DIR --out RUN_DIR [--epochs 60] [--val-every 8] [--device cuda]
6 ml/retrain-loop.sh DATASET_DIR [interval s] [epochs] # retrain periodically
8Requires numpy, torch, and matplotlib (for the scatter plots). On the office machine, `module load python`; its PyTorch cannot find a cuDNN engine for the convolution backward pass, so `train.py` disables cuDNN unless `CUDNN=1` is set.
10## Input
12`ml/features.py` turns each WAV into a log-magnitude spectrogram: 8192-point Hann windows (171 ms, 5.9 Hz bins) every 1024 samples (21 ms), 0 to 6 kHz, in dB relative to the clip's loudest bin, floored at -80 dB and scaled to [0, 1]; 1024 by 141 values per clip, cached as float16 in `DATASET_DIR/ml/cache/`. The long window is chosen because the sheet's low partials lie tens of hertz apart and ring for seconds, so frequency resolution matters more than time resolution. The clip's level does not enter: the model is meant to transfer to recordings without a calibrated level.
14## Model and training
16Six blocks of two 3x3 convolutions with batch normalization and a 2x2 max pool (16 to 128 channels), global average pooling, and a two-layer head. A second input channel carries the frequency coordinate of each row, so that absolute frequency, which is what the physical scale of the sheet sets, survives the pooling. The targets are standardized logarithms and the loss is their mean squared error; AdamW with a one-cycle schedule; the epoch with the lowest validation loss is kept. Every eighth clip by index is held out.
18## Report
20`RUN_DIR/metrics.json` and `RUN_DIR/report.html` (also copied to `DATASET_DIR/ml/report.html`) give, for each target and for E/rho, kappa = h sqrt(E / (12 rho (1 - nu^2))), the area, and the aspect ratio, the relative RMS error and the relative MAE on the held-out clips, the error of predicting the training mean, and R^2, with scatter plots. `DATASET_DIR/ml/history.jsonl` collects one line per run, so the report's last table shows the error against the number of clips.
22## What to expect
24In the linear regime the motion depends on E and rho only through E/rho, and the bending frequencies scale as kappa / L^2; the level-invariant spectrogram therefore determines E/rho, the aspect ratio, and the combination kappa / (Lx Ly) well, while E and rho separately, and h against the size, rest on the nonlinearity (amplitude-dependent frequency shifts at the strike speeds used) and on the contact dynamics. The derived rows of the report show which combinations are identified.
↑↓ move↵openescclose