Skip to content

Commit c2a79fe

Browse files
authored
fix 0 tensor in readme (#721)
1 parent d42b46c commit c2a79fe

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

education/第二天作业.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def forward(self, x):
159159
optimizerD.clear_grad()
160160

161161
errD = errD_real + errD_fake
162-
losses[0].append(errD.numpy()[0])
162+
losses[0].append(float(errD))
163163

164164
############################
165165
# (2) Update G network: maximize log(D(G(z)))
@@ -174,7 +174,7 @@ def forward(self, x):
174174
optimizerG.step()
175175
optimizerG.clear_grad()
176176

177-
losses[1].append(errG.numpy()[0])
177+
losses[1].append(float(errG))
178178

179179

180180
############################
@@ -196,7 +196,7 @@ def forward(self, x):
196196
plt.xticks([])
197197
plt.yticks([])
198198
plt.subplots_adjust(wspace=0.1, hspace=0.1)
199-
msg = 'Epoch ID={0} Batch ID={1} \n\n D-Loss={2} G-Loss={3}'.format(pass_id, batch_id, errD.numpy()[0], errG.numpy()[0])
199+
msg = 'Epoch ID={0} Batch ID={1} \n\n D-Loss={2} G-Loss={3}'.format(pass_id, batch_id, float(errD), float(errG))
200200
print(msg)
201201
plt.suptitle(msg,fontsize=20)
202202
plt.draw()

0 commit comments

Comments
 (0)