1
0
mirror of https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI.git synced 2026-06-06 01:30:24 +08:00

chore(format): run black on dev (#9)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2024-06-07 20:29:03 +09:00
committed by GitHub
parent 96604e8175
commit 44725ddd2c
5 changed files with 31 additions and 10 deletions

View File

@@ -66,13 +66,15 @@ def sequence_mask(
def total_grad_norm(
parameters: Iterator[torch.nn.Parameter], norm_type: float=2.0,
parameters: Iterator[torch.nn.Parameter],
norm_type: float = 2.0,
) -> float:
norm_type = float(norm_type)
total_norm = 0.0
for p in parameters:
if p.grad is None: continue
if p.grad is None:
continue
param_norm = p.grad.data.norm(norm_type)
total_norm += float(param_norm.item()) ** norm_type
total_norm = total_norm ** (1.0 / norm_type)