Skip to content

fix: issue #61 — 対角 self-distance の sqrt NaN 勾配を構造的に修正 - #64

Merged
t-uda merged 3 commits into
uda-lab:mainfrom
koki3070:fix/issue61-diagonal-sqrt
Jun 22, 2026
Merged

fix: issue #61 — 対角 self-distance の sqrt NaN 勾配を構造的に修正#64
t-uda merged 3 commits into
uda-lab:mainfrom
koki3070:fix/issue61-diagonal-sqrt

Conversation

@koki3070

Copy link
Copy Markdown
Contributor

Summary

  • compute_anisotropic_distance_matrixdist_sq == 0(対角 self-distance および coincident 点ペア)を sqrt の計算グラフから除外し、topo loss 学習時の NaN 勾配崩壊を防ぐ
  • ad-hoc eps は追加せず、forward は従来どおり(対角=0、正の非対角は sqrt(dist_sq)
  • 対角・anomaly 検出・coincident 点・近接点の勾配健全性テストを追加

Fixes #61

Test plan

  • uv run pytest tests/test_topology_gradients.py tests/test_topology.py -v
  • uv run python -m tda_ml.main --config dev(topo loss 有効、3 epoch NaN なし完走)
  • CI repro-smoke(マージ後)

Made with Cursor

koki3070 and others added 2 commits June 19, 2026 11:28
off-diagonal のみ sqrt を適用し対角は 0 のまま。ad-hoc eps なし。

Co-authored-by: Cursor <cursoragent@cursor.com>
dist_sq > 0 のみ sqrt を適用する構造的マスクに整理し、
厳密一致点・近接点の勾配健全性テストを追加する。

Co-authored-by: Cursor <cursoragent@cursor.com>
@t-uda
t-uda requested a review from Copilot June 22, 2026 03:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@t-uda

t-uda commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 43a0b98a6c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tda_ml/topology.py
main の sqrt(NUMERICAL_EPS) 方式ではなく、dist_sq > 0 のみ sqrt を適用する
構造的修正を維持。test_topology の対角期待値を 0 に更新。

Co-authored-by: Cursor <cursoragent@cursor.com>
@t-uda
t-uda merged commit 242197e into uda-lab:main Jun 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: 異方性距離行列の self-distance(対角=0)を sqrt 微分すると NaN 勾配 → topo loss 学習が全バッチ NaN で崩壊

3 participants