adversarial confounds: finish the generalization started in #131

Abierto
#149 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
30/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
python

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
0
Forks
0
Merge medio
11 h 17 min
PR fusionados (30 d)
23

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rnabioco/leech

Todos los issues de rnabioco/leech

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.