"doc/git@developer.sourcefind.cn:wangsen/paddle_dbnet.git" did not exist on "8121d5bf5bab5e558078e2999218f18de67b74d0"
Unverified Commit 820807c8 authored by feffy380's avatar feffy380 Committed by GitHub
Browse files

Fix Perp-Neg math

adjust perp-neg implementation to match the paper
parent 18c151b3
...@@ -35,7 +35,7 @@ class PerpNeg: ...@@ -35,7 +35,7 @@ class PerpNeg:
pos = noise_pred_pos - noise_pred_nocond pos = noise_pred_pos - noise_pred_nocond
neg = noise_pred_neg - noise_pred_nocond neg = noise_pred_neg - noise_pred_nocond
perp = ((torch.mul(pos, neg).sum())/(torch.norm(neg)**2)) * neg perp = neg - ((torch.mul(neg, pos).sum())/(torch.norm(pos)**2)) * pos
perp_neg = perp * neg_scale perp_neg = perp * neg_scale
cfg_result = noise_pred_nocond + cond_scale*(pos - perp_neg) cfg_result = noise_pred_nocond + cond_scale*(pos - perp_neg)
cfg_result = x - cfg_result cfg_result = x - cfg_result
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment