def samples_write(self, x, epoch):
_, samples = self.forward(x)
#pdb.set_trace()
samples = samples.data.cpu().numpy()[:16]
fig = plt.figure(figsize=(4, 4))
gs = gridspec.GridSpec(4, 4)
gs.update(wspace=0.05, hspace=0.05)
for i, sample in enumerate(samples):
ax = plt.subplot(gs[i])
plt.axis('off')
ax.set_xticklabels([])
ax.set_yticklabels([])
ax.set_aspect('equal')
plt.imshow(sample.reshape(28, 28), cmap='Greys_r')
if not os.path.exists('out/'):
os.makedirs('out/')
plt.savefig('out/{}.png'.format(str(epoch).zfill(3)), bbox_inches='tight')
#self.c += 1
plt.close(fig)
CAE_pytorch.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录