Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GAN/ali_bigan/ali_bigan_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def reset_grad():
# Print and plot every now and then
if it % 1000 == 0:
print('Iter-{}; D_loss: {:.4}; G_loss: {:.4}'
.format(it, D_loss.data[0], G_loss.data[0]))
.format(it, D_loss.item(), G_loss.item()))

samples = P(z).data.numpy()[:16]

Expand Down
2 changes: 1 addition & 1 deletion GAN/auxiliary_classifier_gan/ac_gan_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def reset_grad():
samples = G(z, c).data.numpy()

print('Iter-{}; D_loss: {:.4}; G_loss: {:.4}; Idx: {}'
.format(it, -D_loss.data[0], -G_loss.data[0], idx))
.format(it, -D_loss.item(), -G_loss.item(), idx))

fig = plt.figure(figsize=(4, 4))
gs = gridspec.GridSpec(4, 4)
Expand Down
4 changes: 2 additions & 2 deletions GAN/boundary_equilibrium_gan/began_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ def reset_grad():

# Update k, the equlibrium
k = k + lam * (gamma*D(X) - D(G(z_G)))
k = k.data[0] # k is variable, so unvariable it so that no gradient prop.
k = k.item() # k is variable, so unvariable it so that no gradient prop.

# Print and plot every now and then
if it % 1000 == 0:
measure = D(X) + torch.abs(gamma*D(X) - D(G(z_G)))

print('Iter-{}; Convergence measure: {:.4}'
.format(it, measure.data[0]))
.format(it, measure.item()))

samples = G(z_G).data.numpy()[:16]

Expand Down
2 changes: 1 addition & 1 deletion GAN/boundary_seeking_gan/bgan_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def reset_grad():
# Print and plot every now and then
if it % 1000 == 0:
print('Iter-{}; D_loss: {:.4}; G_loss: {:.4}'
.format(it, D_loss.data[0], G_loss.data[0]))
.format(it, D_loss.item(), G_loss.item()))

samples = G(z).data.numpy()[:16]

Expand Down
4 changes: 2 additions & 2 deletions GAN/coupled_gan/cogan_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ def sample_x(X, size):
print('Iter-{}; D1_loss: {:.4}; G1_loss: {:.4}; '
'D2_loss: {:.4}; G2_loss: {:.4}'
.format(
it, D1_loss.data[0], G1_loss.data[0],
D2_loss.data[0], G2_loss.data[0])
it, D1_loss.item(), G1_loss.item(),
D2_loss.item(), G2_loss.item())
)

z = Variable(torch.randn(8, z_dim))
Expand Down
2 changes: 1 addition & 1 deletion GAN/disco_gan/discogan_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def sample_x(X, size):
# Print and plot every now and then
if it % 1000 == 0:
print('Iter-{}; D_loss: {:.4}; G_loss: {:.4}'
.format(it, D_loss.data[0], G_loss.data[0]))
.format(it, D_loss.item(), G_loss.item()))

input_A = sample_x(X_train1, size=4)
input_B = sample_x(X_train2, size=4)
Expand Down
2 changes: 1 addition & 1 deletion GAN/dual_gan/dualgan_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def sample_x(X, size):
# Print and plot every now and then
if it % 1000 == 0:
print('Iter-{}; D_loss: {:.4}; G_loss: {:.4}'
.format(it, D1_loss.data[0] + D2_loss.data[0], G_loss.data[0]))
.format(it, D1_loss.item() + D2_loss.item(), G_loss.item()))

real1 = X1.data.numpy()[:4]
real2 = X2.data.numpy()[:4]
Expand Down
2 changes: 1 addition & 1 deletion GAN/ebgan/ebgan_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def reset_grad():
# Print and plot every now and then
if it % 1000 == 0:
print('Iter-{}; D_loss: {:.4}; G_loss: {:.4}'
.format(it, D_loss.data[0], G_loss.data[0]))
.format(it, D_loss.item(), G_loss.item()))

samples = G(z).data.numpy()[:16]

Expand Down
2 changes: 1 addition & 1 deletion GAN/f_gan/f_gan_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def reset_grad():
# Print and plot every now and then
if it % 1000 == 0:
print('Iter-{}; D_loss: {:.4}; G_loss: {:.4}'
.format(it, D_loss.data[0], G_loss.data[0]))
.format(it, D_loss.item(), G_loss.item()))

samples = G(z).data.numpy()[:16]

Expand Down
2 changes: 1 addition & 1 deletion GAN/generative_adversarial_parallelization/gap_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def reset_grad():
# Print and plot every now and then
if it % 1000 == 0:
print('Iter-{}; D_loss: {:.4}; G_loss: {:.4}'
.format(it, D_loss.data[0], G_loss.data[0]))
.format(it, D_loss.item(), G_loss.item()))

# Pick G randomly
G_rand = random.choice([G1_, G2_])
Expand Down
3 changes: 1 addition & 2 deletions GAN/gibbsnet/gibbsnet_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def reset_grad():
P.zero_grad()
D_.zero_grad()


G_solver = optim.Adam(chain(Q.parameters(), P.parameters()), lr=lr)
D_solver = optim.Adam(D_.parameters(), lr=lr)

Expand Down Expand Up @@ -99,7 +98,7 @@ def reset_grad():
# Print and plot every now and then
if it % 100 == 0:
print('Iter-{}; D_loss: {:.4}; G_loss: {:.4}'
.format(it, D_loss.data[0], G_loss.data[0]))
.format(it, D_loss.item(), G_loss.item()))

z = Variable(torch.randn(mb_size, z_dim))

Expand Down
2 changes: 1 addition & 1 deletion GAN/least_squares_gan/lsgan_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def reset_grad():
# Print and plot every now and then
if it % 1000 == 0:
print('Iter-{}; D_loss: {:.4}; G_loss: {:.4}'
.format(it, D_loss.data[0], G_loss.data[0]))
.format(it, D_loss.item(), G_loss.item()))

samples = G(z).data.numpy()[:16]

Expand Down
4 changes: 2 additions & 2 deletions GAN/magan/magan_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ def reset_grad():
reset_grad()

if it % 1000 == 0:
print('Iter-{}; Pretrained D loss: {:.4}'.format(it, loss.data[0]))
print('Iter-{}; Pretrained D loss: {:.4}'.format(it, loss.item()))


# Initial margin, expected energy of real data
m = torch.mean(D(Variable(torch.from_numpy(mnist.train.images)))).data[0]
m = torch.mean(D(Variable(torch.from_numpy(mnist.train.images)))).item()
s_z_before = torch.from_numpy(np.array([np.inf], dtype='float32'))


Expand Down
2 changes: 1 addition & 1 deletion GAN/softmax_gan/softmax_gan_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def reset_grad():
# Print and plot every now and then
if it % 1000 == 0:
print('Iter-{}; D_loss: {:.4}; G_loss: {:.4}'
.format(it, D_loss.data[0], G_loss.data[0]))
.format(it, D_loss.item(), G_loss.item()))

samples = G(z).data.numpy()[:16]

Expand Down
2 changes: 1 addition & 1 deletion VAE/adversarial_autoencoder/aae_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def sample_X(size, include_y=False):
# Print and plot every now and then
if it % 1000 == 0:
print('Iter-{}; D_loss: {:.4}; G_loss: {:.4}; recon_loss: {:.4}'
.format(it, D_loss.data[0], G_loss.data[0], recon_loss.data[0]))
.format(it, D_loss.item(), G_loss.item(), recon_loss.item()))

samples = P(z_real).data.numpy()[:16]

Expand Down
2 changes: 1 addition & 1 deletion VAE/adversarial_vb/avb_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def sample_X(size, include_y=False):
# Print and plot every now and then
if it % 1000 == 0:
print('Iter-{}; ELBO: {:.4}; T_loss: {:.4}'
.format(it, -elbo.data[0], -T_loss.data[0]))
.format(it, -elbo.item(), -T_loss.item()))

samples = P(z).data.numpy()[:16]

Expand Down
2 changes: 1 addition & 1 deletion VAE/conditional_vae/cvae_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def P(z, c):

# Print and plot every now and then
if it % 1000 == 0:
print('Iter-{}; Loss: {:.4}'.format(it, loss.data[0]))
print('Iter-{}; Loss: {:.4}'.format(it, loss.item()))

c = np.zeros(shape=[mb_size, y_dim], dtype='float32')
c[:, np.random.randint(0, 10)] = 1.
Expand Down
2 changes: 1 addition & 1 deletion VAE/denoising_vae/dvae_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def P(z):

# Print and plot every now and then
if it % 1000 == 0:
print('Iter-{}; Loss: {:.4}'.format(it, loss.data[0]))
print('Iter-{}; Loss: {:.4}'.format(it, loss.item()))

z = Variable(torch.randn(mb_size, Z_dim))
samples = P(z).data.numpy()[:16]
Expand Down
2 changes: 1 addition & 1 deletion VAE/vanilla_vae/vae_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def P(z):

# Print and plot every now and then
if it % 1000 == 0:
print('Iter-{}; Loss: {:.4}'.format(it, loss.data[0]))
print('Iter-{}; Loss: {:.4}'.format(it, loss.item()))

samples = P(z).data.numpy()[:16]

Expand Down