Skip to content

Commit 3e79806

Browse files
Update MNIST Classification Model..py
Added Logging for Loss vs Epoch
1 parent 6395e59 commit 3e79806

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

MNIST Classification Model..py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
train_batch = tch.utils.data.DataLoader(train, batch_size=30, shuffle=True)
1414

15-
1615
input = 784
1716
hidden = 490
1817
output = 10
@@ -40,13 +39,16 @@
4039
optimize.zero_grad()
4140
output = model(images)
4241
loss = lossfn(output, labels)
42+
writer.add_scalar("Loss", loss, num)
4343
loss.backward()
4444
optimize.step()
4545
run += loss.item()
4646
else:
4747
print("Epoch Number : {} = Loss : {}".format(num, run/len(train_batch)))
4848
Elapsed=(time()-time_start)/60
4949
print("\nTraining Time (in minutes) : ",Elapsed)
50+
writer.flush()
51+
writer.close()
5052

5153
correct=0
5254
all = 0

0 commit comments

Comments
 (0)