Skip to content

Commit f5c7960

Browse files
committed
fix: Fixed training procedure
Detaching the output tensor ended up in a training failure.
1 parent a099e01 commit f5c7960

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

train.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def train_GAN(D, d_optimizer, G, g_optimizer, data_loader, fixed_z, n_epochs, tr
4949
D_real = D(real_images).squeeze()
5050
# Generate fake images
5151
z = get_noise((batch_size, fixed_z.size(1)), train_on_gpu)
52-
D_fake = D(G(z)).detach().squeeze()
52+
D_fake = D(G(z)).squeeze()
5353

5454
# Compute loss
5555
d_loss = get_discriminator_loss(D_real, D_fake, real_target, fake_target, loss_type=loss_type)
@@ -64,8 +64,6 @@ def train_GAN(D, d_optimizer, G, g_optimizer, data_loader, fixed_z, n_epochs, tr
6464

6565
g_optimizer.zero_grad()
6666

67-
# Get discrimminator output for real and fake images
68-
D_real = D(real_images).detach().squeeze()
6967
# Get discrimminator output for fake images
7068
z = get_noise((batch_size, fixed_z.size(1)), train_on_gpu)
7169
D_fake = D(G(z)).squeeze()

0 commit comments

Comments
 (0)