Repository navigation
fix(simclr): normalise per series and turn off permutation in the default augmentation - #107
aryamaan-roy wants to merge 5 commits into
Conversation
…m features Permutation off by default, per-timestep weak view, instance_normalize in training and encode() (chronocratic#99).
| if max_segments > 1 | ||
| else jitter | ||
| ) | ||
| return RolePairProducer(first=TSTCCScaling(), second=strong) |
There was a problem hiding this comment.
It is wrong to use TSTCCScaling here. Please change its name, move it somewhere else, or make a new one for SimCLR.
There was a problem hiding this comment.
Moved it to chronocratic.models.augmentation.primitives as TimestepScaling, next to Scaling. TS-TCC and SimCLR both import it from there.
| from chronocratic.models.convolutional.standard.encoders.resnet import Conv1dResNetEncoder | ||
| from chronocratic.models.convolutional.standard.simclr.augmentations import _default_simclr_pair | ||
| from chronocratic.models.convolutional.standard.simclr.config import _MIN_SINGLETON_SPLIT_COUNT | ||
| from chronocratic.models.convolutional.standard.tstcc.model import _instance_normalize |
There was a problem hiding this comment.
It is wrong to use private functions outside tstcc. This needs to be restructured so that the function exists where both models can reach it.
There was a problem hiding this comment.
Moved it to chronocratic.models.utils as the public normalize_per_series, next to zero_fill_padding. Both models import it from there.
TSTCCScaling is now TimestepScaling in augmentation.primitives; _instance_normalize is now utils.normalize_per_series.
skafai
left a comment
There was a problem hiding this comment.
Hi @aryamaan-roy ,
See the requested changes.
| # --------------------------------------------------------------------------- # | ||
|
|
||
|
|
||
| @dataclass |
There was a problem hiding this comment.
These two should not be primitives, because they are not.
Consider moving them somewhere like
src/chronocratic/models/convolutional/standard/augmentaion/timestep_scaling.py (augmentation can be a package with init to export this method in a barell)
There was a problem hiding this comment.
Moved both out of primitives.py into convolutional/standard/augmentation/timestep_scaling.py, with an init.py that re-exports them.
Fixes #99.
Problem
With its default augmentation, a trained SimCLR encoder scores lower than an untrained one in a linear-probe evaluation: 61% against 66% on CricketX, and 40% against 58% on InsectWingbeatSound.
GroupNorm(1, C)cancels.Changes
Same pattern as #100:
TSTCCScaling(per-timestep) as the weak view andJitter(0.8)as the strong view, with permutation off._default_simclr_pair(max_segments=5)restores the reference's strong view.instance_normalize=True: per-series z-normalisation over time, in training and inencode().instance_normalize=False, becauseencode()now normalises its input.Testing
tests/integration/test_simclr_learns.py: it fails on the old code and passes with the fix. It checks normalisation only; the probe below covers permutation.instance_normalize.Probe accuracy at B=128, mean of 3 seeds. The probe is an RBF SVM on
encode()features (TS2Vec protocol), and the old pair was run with normalisation on, so only the augmentation differs:At B=16 the new default gives 70% and 62%. ECG5000, FordA and TwoPatterns are within about 1 point under every setting.