Make grad_norm and combined_grad_norm None is not recording

This commit is contained in:
rockerBOO
2025-05-01 01:37:57 -04:00
parent 80320d21fe
commit f62c68df3c
2 changed files with 10 additions and 8 deletions

View File

@@ -1444,8 +1444,10 @@ class NetworkTrainer:
else:
if hasattr(network, "weight_norms"):
mean_norm = network.weight_norms().mean().item()
mean_grad_norm = network.grad_norms().mean().item()
mean_combined_norm = network.combined_weight_norms().mean().item()
grad_norms = network.grad_norms()
mean_grad_norm = grad_norms.mean().item() if grad_norms is not None else None
combined_weight_norms = network.combined_weight_norms()
mean_combined_norm = combined_weight_norms.mean().item() if combined_weight_norms is not None else None
weight_norms = network.weight_norms()
maximum_norm = weight_norms.max().item() if weight_norms.numel() > 0 else None
keys_scaled = None