adversarial confounds: finish the generalization started in #131

オープン
#149 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
30/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
0
フォーク
0
平均マージ
11時間 17分
マージ済み PR(30日)
23

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rnabioco/leech のほかの issue

rnabioco/leech の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。