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

Function DrawGen

WGANGPCode/draw.py:12–35  ·  view source on GitHub ↗

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

(model,epoch,test_input)

Source from the content-addressed store, hash-verified

10
11#绘图函数
12def DrawGen(model,epoch,test_input):
13 """
14 :param model: 生成器训练的模型
15 :param epoch: 迭代次数
16 :param test_input: 对产生的噪声生成图像
17 :return:
18 """
19 result = model(test_input).detach().cpu()
20 #将维度为1的进行压缩
21 #--------------------------------------------------------------
22 # vutilsImg = vutils.make_grid(result, padding=2, normalize=True)
23 # fig = plt.figure(figsize=(4, 4))
24 # plt.imshow(np.transpose(vutilsImg, (1, 2, 0)))
25 # plt.axis('off')
26 # plt.show()
27 # --------------------------------------------------------------
28 result = np.squeeze(result.numpy())
29 fig = plt.figure(figsize=(4,4))
30 for i in range(16):
31 plt.subplot(4, 4, i + 1)
32 plt.imshow(np.transpose(result[i],(1,2,0)))
33 plt.axis('off')
34 plt.savefig('images/{}.png'.format(epoch))
35 #--------------------------------------------------------------

Callers 1

train.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected