adversarial confounds: finish the generalization started in #131

Aperta
#149 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python

Direzione di ricerca

Start in src/leech/confounds.py at DISC_BASE_TO_INT, the disc_base builtin branch around lines 408-420, and load_confound_config around lines 311-352, then read training.py where self.adversarial_head is held. Done means disc_base becomes a plain lookup spec keyed through label_map with num_classes derived from the table, multiple confounds are accepted by cli.py and summed in training, and adversarial_num_classes defaults to None and is required when adversarial_lambda is above 0.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement

Found during the generalization audit (#125). Follows on from the config-driven confound work in d3b4fe6 (#131).

The ConfoundSpec design from #131 is good and genuinely generic. Three gaps remain.

1. disc_base still forces a 4-class nucleotide space

src/leech/confounds.py:38-40 — DISC_BASE_TO_INT = {"A": 0, "C": 1, "G": 2, "T": 3} / NUM_DISC_BASES = 4
src/leech/confounds.py:151 — path = parent / "disc_base_map.json" (filename not configurable)
src/leech/confounds.py:408-420 — the spec.builtin == "disc_base" branch forces source="label_int" and num_classes=4 regardless of how many distinct categories the loaded map actually contains.

The genuinely reusable idea here is composing a lookup table through label_map (class name → label_int → category), which the generic lookup path cannot currently express — generic lookup keys on the raw chunk value. The A/C/G/T alphabet is not reusable.

Fix: add ConfoundSpec(key_via="label_map") so any lookup table can be keyed by class name, and derive num_classes = len(set(table.values())) instead of using a constant. disc_base then collapses to a plain spec with no builtin special-casing:

ConfoundSpec(source="label_int", mapping="lookup", table="disc_base_map.json", key_via="label_map")

2. Only one confound is supported despite list-valued config

confounds.py:311-352 (load_confound_config) parses a list of specs, but cli.py:33-38 rejects anything but one:

if len(specs) != 1:
    raise ... "--confound-config must define exactly one confound, found {len(specs)}"

and training.py:247 holds a single self.adversarial_head.

Fix: hold list[AdversarialHead] keyed by encoder name and sum the losses, with per-confound lambdas.

3. adversarial_num_classes defaults to 4

training.py:228 — adversarial_num_classes: int = 4,
training.py:1219 — adversarial_num_classes = 4 # default class count when adversarial is off

A nucleotide-alphabet default sitting in a generic trainer. Low blast radius (overwritten by confound_encoder.num_classes when adversarial training is on), but it should be int | None = None and required whenever adversarial_lambda > 0.

Lingua principale
Python
Stelle
0
Fork
0
Merge medio
11h 17m
PR unite (30g)
23

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rnabioco/leech

Tutte le issue di rnabioco/leech

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.