Skip to content

Commit

Permalink
Min-SNR Weighting Strategy: Fixed SNR calculation to authors implemen…
Browse files Browse the repository at this point in the history
…tation
  • Loading branch information
AI-Casanova committed Mar 23, 2023
1 parent 64c9232 commit a3c7d71
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/custom_train_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def apply_snr_weight(loss, latents, noisy_latents, gamma):
gamma_over_snr = torch.div(torch.ones_like(snr)*gamma,snr)
snr_weight = torch.minimum(gamma_over_snr,torch.ones_like(gamma_over_snr)).float() #from paper
loss = loss * snr_weight
print(snr_weight)
#print(snr_weight)
return loss

def add_custom_train_arguments(parser: argparse.ArgumentParser):
parser.add_argument("--min_snr_gamma", type=float, default=0, help="gamma for reducing the weight of high loss timesteps. Lower numbers have stronger effect. 5 is recommended by paper.")
parser.add_argument("--min_snr_gamma", type=float, default=0, help="gamma for reducing the weight of high loss timesteps. Lower numbers have stronger effect. 5 is recommended by paper.")

0 comments on commit a3c7d71

Please sign in to comment.