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

Function DrawGen

DCGAN/DCGAN.py:63–86  ·  view source on GitHub ↗

:param model: 生成器训练的模型 :param epoch: 迭代次数 :param test_input: 对产生的噪声生成图像 :return:

(model,epoch,test_input)

Source from the content-addressed store, hash-verified

61
62#绘图函数
63def DrawGen(model,epoch,test_input):
64 """
65 :param model: 生成器训练的模型
66 :param epoch: 迭代次数
67 :param test_input: 对产生的噪声生成图像
68 :return:
69 """
70 result = model(test_input).detach().cpu()
71 #将维度为1的进行压缩
72 #--------------------------------------------------------------
73 # vutilsImg = vutils.make_grid(result, padding=2, normalize=True)
74 # fig = plt.figure(figsize=(4, 4))
75 # plt.imshow(np.transpose(vutilsImg, (1, 2, 0)))
76 # plt.axis('off')
77 # plt.show()
78 # --------------------------------------------------------------
79 result = np.squeeze(result.numpy())
80 fig = plt.figure(figsize=(4,4))
81 for i in range(16):
82 plt.subplot(4, 4, i + 1)
83 plt.imshow(np.transpose(result[i],(1,2,0)))
84 plt.axis('off')
85 plt.savefig('images/{}.png'.format(epoch))
86 #--------------------------------------------------------------
87
88#训练迭代的次数
89epoches = 20

Callers 1

DCGAN.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected