Hi sami,
I have the same issue. I loaded weights file and generated image from weights. It seemed that using random noise not really learnt weights. Have you figured out why is that? I haven’t successfully generated one image for now.
I’m using torch 0.4.1.
Weights file is saved via torch.save(generator.state_dict(), path) during training phase.
During testing phase, I did:
model = generator()
checkpoint = torch.load(‘path/001_G.pth’, map_location = str(device))
model.load_state_dict(checkpoint, strict=False)
model.to(device)
model.float()
model.eval()
def label_sampel():
label = torch.LongTensor(batch_size, 1).random_()%n_class
one_hot= torch.zeros(batch_size, n_class).scatter_(1, label, 1)
print(device)
return label.squeeze(1).to(device), one_hot.to(device)
z = torch.randn(batch_size, z_dim).to(device)
z_class, z_class_one_hot = label_sampel()
fake_images = model(z, z_class_one_hot)
save_image(denorm(fake_images.data), os.path.join(path, ‘1_generated.png’))