File tree 1 file changed +9
-2
lines changed 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ def training(opt):
49
49
50
50
writer_fake = SummaryWriter (f"{ str (log_dir )} /fake" )
51
51
writer_real = SummaryWriter (f"{ str (log_dir )} /real" )
52
+ loss_writer = SummaryWriter (f"{ str (log_dir )} /loss" )
52
53
53
54
# ~~~~~~~~~~~~~~~~~~~ loading the model ~~~~~~~~~~~~~~~~~~~ #
54
55
@@ -76,10 +77,12 @@ def training(opt):
76
77
criterion = torch .nn .BCELoss ()
77
78
78
79
# ~~~~~~~~~~~~~~~~~~~ training loop ~~~~~~~~~~~~~~~~~~~ #
80
+ D_loss_prev = math .inf
81
+ G_loss_prev = math .inf
82
+ D_loss = 0
83
+ G_loss = 0
79
84
80
85
for epoch in range (EPOCHS ):
81
- D_loss_prev = math .inf
82
- G_loss_prev = math .inf
83
86
84
87
for batch_idx , (real , _ ) in enumerate (tqdm (loader )):
85
88
disc .train ()
@@ -148,6 +151,10 @@ def training(opt):
148
151
writer_real .add_image (
149
152
"Mnist Real Images" , img_grid_real , global_step = epoch
150
153
)
154
+ loss_writer .add_scalar (
155
+ 'discriminator' , D_loss , global_step = epoch )
156
+ loss_writer .add_scalar (
157
+ 'generator' , G_loss , global_step = epoch )
151
158
152
159
# ~~~~~~~~~~~~~~~~~~~ saving the weights ~~~~~~~~~~~~~~~~~~~ #
153
160
if opt .weights :
You can’t perform that action at this time.
0 commit comments