Repository navigation
Behaviour fixes and reorganisation; fix the DAF duration metric - #14
Merged
Merged
Conversation
…nsform, stimulus metadata, new constants VocalErrorNetV2 is kept as a subclass with its earlier defaults, so existing callers (finchsim) behave as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- train_ven's per-rendition monitoring draws its own noise, so training no longer depends on logging; the network is retrained (within noise of the previous one) and a pure-defaults run reproduces it byte-for-byte. - daf_response searches for the end of a response up to 300 ms after onset (capped at the motif end) instead of dropping responders still responding at 150 ms; responses still running at the window end are counted at the length reached and reported as censored. Fixes two off-by-ones in the onset/offset searches. Duration 46.4 -> 47.5 ms at the test seed (5-seed mean 45.9 -> 46.0); no other metric changes. - Known-answer tests for latency and duration (tests/test_metrics.py). - README: links to docs/MODEL.md and design notes; stimulus provenance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Points 3 (behaviour fixes) and 4 (organisation) from the review, plus the duration-metric fix.
Organisation
VocalErrorNetreplacesVocalErrorNetV2. Its defaults are the shipped operating point, soVocalErrorNet(n_aud=encoder.n_channels)builds the published network;n_audis required.VocalErrorNetV2stays as a subclass with its old defaults unchanged, because finchsim's tests build networks from them. finchsim's spiking-ven tests give the same result against this branch (12 passed, 3 skipped).Every trained value now lives in
constants.py:TAU_I,C_JEI,NOISE_E,NOISE_I,TARGET_RATE_E,TARGET_RATE_IandT_REFR_MS, which existed only as class defaults, plus the encoder front end (CAUSAL_N_BASES,CAUSAL_K_FRAMES,CAUSAL_N_COCH_CH,CAUSAL_FRAME_RATE,CAUSAL_LO_HZ,CAUSAL_HI_HZ,CAUSAL_RMS_REF). All match the shipped artifacts. Units are documented.evaluate.pysplit intostimuli.py,metrics.pyandtargets.py;evaluate.pyremains as a re-export.K labels removed:
daf_metricsrendition_ratesformat_metricsformat_rendition_ratesk1trained_hzk4_ratereversed_hzk4reversed_over_trainedk2_no_hvcdaf_not_singing_hzrctrained_hzrnreversed_hzjiejie_meanrc_hvcetc.final_*New docs:
docs/MODEL.md(equations as implemented, units, glossary), linked from the README.Behaviour fixes
load()is strict: missing required keys raise an error that lists them all; features added after the first saved models load with documented "off" defaults.ven.stimulus): sample rate, seed, protocol timing, rate calibration, DAF window, and checksums of the encoder and corpus.sven-evaluateandsven-figurerebuild from that record, warn when a flag overrides it or a checksum differs, and taken_hvcfrom the model (sven-evaluate --n-hvcis removed). New flags:--daf-window-s,--stimulus-seed.build_stimulithrough the metrics and the PSTH figure; nothing hardcodes the 400 ms onset or the 50 ms burst any more.srdefaults to the corpus's own rate, and a mismatch is an error.motifs.npzstorestemplate_index, the DTW reference. The shipped corpus has no such key and still picks template 25.Duration metric
The end of a response is now searched for up to 300 ms after onset, capped at the motif end, instead of dropping responders still responding at 150 ms. Responses still running at the window end are counted at the length reached and reported as censored. Two off-by-ones are fixed. Only duration changes: 46.4 → 47.5 ms at the test seed (5-seed mean 45.9 → 46.0). The model's responses really are at the bird's lower edge (47 ms).
Known-answer tests show latency is recovered exactly, while the paper's duration rule reads about 8 ms long, because chance-significant baseline bins postpone the 10-bin end run. The bird's number was measured with the same rule, so the comparison is like for like.
Retrained network
Retrained only because training no longer shares its noise with monitoring. Every metric is within its 5-seed spread of the previous model, and the reversed/trained ratio is 1.174 vs 1.173. A pure-defaults run reproduces
ven_model.npzbyte-for-byte;MANIFEST.sha256is updated. The encoder and corpus are unchanged.Pinned values (seed 42): responders 52.2%, baseline 2.52 Hz, latency 30.5 ms, duration 47.5 ms, extra spikes 1.74, peak 44.6 Hz.
Verification
183 tests pass (fast and slow, including Brian2 parity at the operating point);
ruffclean. Evaluating the previous shipped model gives identical metrics before and after the refactor.Before merging
Copy the new
outputs/ven_model.npzandven_model_traces.npzinto existing checkouts (or runmake clean-artifacts && make figure); the encoder andmotifs.npzare unchanged.🤖 Generated with Claude Code