Unverified Commit 47c95709 authored by yuanzhoulvpi's avatar yuanzhoulvpi Committed by GitHub
Browse files

fix error: TypeError: Object of type Tensor is not JSON serializable … (#29568)



fix error: TypeError: Object of type Tensor is not JSON serializable trainer
Co-authored-by: default avatarZach Mueller <muellerzr@gmail.com>
parent e5eb55b8
......@@ -2415,7 +2415,7 @@ class Trainer:
logs["loss"] = round(tr_loss_scalar / (self.state.global_step - self._globalstep_last_logged), 4)
if grad_norm is not None:
logs["grad_norm"] = grad_norm.item() if torch.is_tensor(grad_norm) else grad_norm
logs["grad_norm"] = grad_norm.detach().item() if isinstance(grad_norm, torch.Tensor) else grad_norm
logs["learning_rate"] = self._get_learning_rate()
self._total_loss_scalar += tr_loss_scalar
......
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