-
Notifications
You must be signed in to change notification settings - Fork 1
fix: issue #59 — ad-hoc 微小正定数の整理と論文外モデリング床の削除 #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Issue #59 verification: reproduce_1week_tuned + mahalanobis + early MCC abort + diagnostics. | ||
| # Mahalanobis only; aborts if MCC stays ~0 after probe_epochs (default 8 — size reg needs epochs). | ||
|
|
||
| meta: | ||
| config_id: "issue59_verify_mahalanobis" | ||
|
|
||
| model: | ||
| point_dim: 2 | ||
| feature_dim: 128 | ||
| threshold: 0.5 | ||
| topology_loss: | ||
| distance_backend: "mahalanobis" | ||
| ellphi_differentiable: true | ||
|
|
||
| loss: | ||
| w_class: 1.0 | ||
| w_topo: 0.2 | ||
| w_aniso: 0.01099204345474479 | ||
| w_size: 0.0005578582308620256 | ||
| pos_weight: 1.0 | ||
| aniso_mode: "linear" | ||
|
|
||
| training: | ||
| lr: 0.0004897466143769238 | ||
| epochs: 12 | ||
| grad_clip_value: 1.0 | ||
| visualize_every: 1 | ||
| warmup_epochs: 0 | ||
| use_amp: true | ||
| early_abort: | ||
| enabled: true | ||
| probe_epochs: 8 | ||
| min_val_mcc: 0.05 | ||
| min_train_mcc: 0.02 | ||
| max_val_recall_for_abort: 0.99 | ||
|
|
||
| data: | ||
| max_points: 100 | ||
| num_outliers: 20 | ||
| seed: 42 | ||
| test_size: 1000 | ||
| num_workers: 4 | ||
| batch_size: 16 | ||
| pin_memory: true | ||
|
|
||
| performance: | ||
| cudnn_benchmark: true | ||
| enable_tf32: true | ||
| matmul_precision: high | ||
|
|
||
| outputs: | ||
| base_dir: "outputs" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| Issue #59 supervised verification (mahalanobis, reproduce_1week_tuned hyperparameters). | ||
|
|
||
| Runs training with early abort when val/train MCC stay near zero after probe_epochs. | ||
| On abort, writes ``logs/issue59_abort_report.{json,md}`` with ellipse / encoder / | ||
| distance / classification diagnostics and ranked failure hypotheses. | ||
|
|
||
| Usage:: | ||
|
|
||
| uv run python experiments/issue59_verify_mahalanobis.py | ||
| uv run python experiments/issue59_verify_mahalanobis.py --epochs 12 --seed 42 | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import argparse | ||
| import json | ||
| from pathlib import Path | ||
|
|
||
| from tda_ml.config import deep_update, load_config | ||
| from tda_ml.main import main as train_main | ||
| from tda_ml.supervised_diagnostics import git_revision | ||
|
|
||
| REPO = Path(__file__).resolve().parents[1] | ||
|
|
||
|
|
||
| def preflight(config_name: str) -> dict: | ||
| cfg = load_config(config_name, project_root=REPO) | ||
| data = cfg.get("data", {}) | ||
| training = cfg.get("training", {}) | ||
| early = training.get("early_abort", {}) | ||
| if not early.get("enabled", False): | ||
| raise ValueError( | ||
| f"{config_name}: training.early_abort.enabled must be true for verification" | ||
| ) | ||
| backend = ( | ||
| cfg.get("model", {}).get("topology_loss", {}).get("distance_backend", "") | ||
| ) | ||
| if backend != "mahalanobis": | ||
| raise ValueError( | ||
| f"issue59 verification expects mahalanobis backend; got {backend!r}" | ||
| ) | ||
| data_root = REPO / "data" | ||
| if not data_root.exists(): | ||
| raise FileNotFoundError( | ||
| f"MNIST data root missing: {data_root}. Run training once to download." | ||
| ) | ||
| return { | ||
| "config_id": cfg["meta"].get("config_id"), | ||
| "source_revision": git_revision(REPO), | ||
| "epochs": training.get("epochs"), | ||
| "seed": data.get("seed"), | ||
| "early_abort": early, | ||
| "distance_backend": backend, | ||
| } | ||
|
|
||
|
|
||
| def main() -> int: | ||
| parser = argparse.ArgumentParser(description=__doc__) | ||
| parser.add_argument( | ||
| "--config", | ||
| default="issue59_verify_mahalanobis", | ||
| help="Config name under configs/ (default: issue59_verify_mahalanobis)", | ||
| ) | ||
| parser.add_argument("--epochs", type=int, default=None) | ||
| parser.add_argument("--seed", type=int, default=None) | ||
| parser.add_argument( | ||
| "--out-base", | ||
| type=Path, | ||
| default=REPO / "outputs" / "issue59_verify", | ||
| ) | ||
| args = parser.parse_args() | ||
|
|
||
| manifest_preview = preflight(args.config) | ||
| print("=== Preflight OK ===") | ||
| print(json.dumps(manifest_preview, indent=2, ensure_ascii=True)) | ||
|
|
||
| cfg = load_config(args.config, project_root=REPO) | ||
| overrides: dict = {"outputs": {"base_dir": str(args.out_base)}} | ||
| if args.epochs is not None: | ||
| overrides.setdefault("training", {})["epochs"] = args.epochs | ||
| if args.seed is not None: | ||
| overrides.setdefault("data", {})["seed"] = args.seed | ||
| cfg = deep_update(cfg, overrides) | ||
|
|
||
| result = train_main(config=cfg) | ||
| status = result.get("status", "completed") | ||
| print("\n=== Verification result ===") | ||
| print(f"status: {status}") | ||
| print(f"run_dir: {result.get('run_dir')}") | ||
| print(f"best_val_mcc: {result.get('best_val_mcc', result.get('val_mcc')):.4f}") | ||
| if result.get("abort_report"): | ||
| print(f"abort_report: {result['abort_report']}") | ||
| print("\nReview hypotheses in issue59_abort_report.md before long runs.") | ||
| return 2 | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| raise SystemExit(main()) |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.