MCPcopy Create free account
hub / github.com/KeepTryingTo/Pytorch-GAN / plot_to_tensorboard

Function plot_to_tensorboard

StyleGAN/utils.py:17–30  ·  view source on GitHub ↗
(
    writer, loss_critic, loss_gen, real, fake, tensorboard_step
)

Source from the content-addressed store, hash-verified

15
16# Print losses occasionally and print to tensorboard
17def plot_to_tensorboard(
18 writer, loss_critic, loss_gen, real, fake, tensorboard_step
19):
20 writer.add_scalar("Loss Critic", loss_critic, global_step=tensorboard_step)
21
22 with torch.no_grad():
23 # take out (up to) 32 examples
24 img_grid_real = torchvision.utils.make_grid(real[:8], normalize=True)
25 img_grid_fake = torchvision.utils.make_grid(fake[:8], normalize=True)
26 writer.add_image("Real", img_grid_real, global_step=tensorboard_step)
27 writer.add_image("Fake", img_grid_fake, global_step=tensorboard_step)
28 #保存图像到images文件下
29 save_image(img_grid_fake,os.path.join('images','fake_' + str(tensorboard_step) + '.png'))
30 save_image(img_grid_real,os.path.join('images','real_' + str(tensorboard_step) + '.png'))
31
32
33#这里沿用了GP-GAN中的公式

Callers 1

train_fnFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected