From e6dd99c0ffed3492bf35dcb790ae10a8170e93e8 Mon Sep 17 00:00:00 2001 From: Python Engineer Date: Tue, 13 Oct 2020 17:38:45 +0200 Subject: [PATCH] fixed running accuracy calculation in 16_tensorboard --- 16_tensorboard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/16_tensorboard.py b/16_tensorboard.py index f3662148..0bd67dc6 100644 --- a/16_tensorboard.py +++ b/16_tensorboard.py @@ -113,7 +113,8 @@ def forward(self, x): print (f'Epoch [{epoch+1}/{num_epochs}], Step [{i+1}/{n_total_steps}], Loss: {loss.item():.4f}') ############## TENSORBOARD ######################## writer.add_scalar('training loss', running_loss / 100, epoch * n_total_steps + i) - writer.add_scalar('accuracy', running_correct / 100, epoch * n_total_steps + i) + running_accuracy = running_correct / 100 / predicted.size(0) + writer.add_scalar('accuracy', running_accuracy, epoch * n_total_steps + i) running_correct = 0 running_loss = 0.0 ###################################################