计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
pairwise_similarity_preservation【效率与协作】Compute DDPM-PA pairwise cosine-softmax distributions and adapted-to-source KL preservation loss.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this skill when implementing the DDPM-PA relative-distance preservation term. It compares the geometry of source and adapted generated samples by converting pairwise cosine similarities into per-anchor probability distributions and minimizing KL divergence.
Do not use this skill to compare images to target training images directly. It preserves relative geometry between source and adapted predictions, while target-detail matching belongs to the high-frequency module.
KL(p_adapted || p_source).Run:
python scripts/pairwise_loss.py --smoke
python -m pytest tests
The tests check zero loss for identical geometry, positive loss for changed geometry, and no self-index in neighbor lists.
The included implementation is deterministic and standard-library only. For tensor frameworks, keep the same anchor-wise exclusion and KL direction; changing either changes the paper mechanism.