我是 python 编码和使用 tensorflow 的新手,据说这可能是一个愚蠢的问题。我正在关注 Siraj 完成的pokeGAN 教程,他并没有真正评论测试功能。我已经训练了模型,但是当我取消注释测试函数时,它只是以代码 0 退出,并且没有给我它可能生成的图像。我知道退出代码 0 意味着没有错误,但我很好奇它为什么不生成图像。函数只是没有告诉它生成图像吗?是否还有其他需要取消注释(或注释)才能使其正常工作的内容?任何帮助都会很棒。
这是完整代码的 github 链接:pokeGAN
这是实际的测试功能:
def test():
random_dim = 100
with tf.variable_scope('input'):
real_image = tf.placeholder(tf.float32, shape=[None, HEIGHT, WIDTH, CHANNEL], name='real_image')
random_input = tf.placeholder(tf.float32, shape=[None, random_dim], name='rand_input')
is_train = tf.placeholder(tf.bool, name='is_train')
# wgan
fake_image = generator(random_input, random_dim, is_train)
real_result = discriminator(real_image, is_train)
fake_result = discriminator(fake_image, is_train, reuse=True)
sess = tf.InteractiveSession()
sess.run(tf.global_variables_initializer())
variables_to_restore = slim.get_variables_to_restore(include=['gen'])
print(variables_to_restore)
saver = tf.train.Saver(variables_to_restore)
ckpt = tf.train.latest_checkpoint('./model/' + version)
saver.restore(sess, ckpt)