我试图用Tensorflow模型(元计时器和检查点)恢复生成对抗网络的经过训练的生成器。
我刚接触过tensorflow和python,所以我不确定我所做的是否有意义。已经尝试过从元文件中导入元计时器并从检查点恢复变量,但是我确定下一步该做什么。我的目标是从上一个检查点恢复经过训练的生成器,然后使用它从噪声输入生成新的数据。
下面是一个包含模型文件的驱动器的链接:Fq?usp=sharing
到目前为止,我已经尝试了以下方法,它似乎正在加载图形:
# import the graph from the file
imported_graph = tf.train.import_meta_graph("../../models/model-9.meta")
# list all the tensors in the graph
for tensor in tf.get_default_graph().get_operations():
print (tensor.name)
# run the session
with tf.Session() as sess:
# restore the saved vairable
imported_graph.restore(sess, "../../models/model-9")然而,我不知道下一步该做什么。是否可以使用这些文件只运行经过训练的生成器?我怎么才能拿到呢?
发布于 2019-11-09 09:45:45
在Tensorflow 2文档中,它们保存--生成器和鉴别器--。但是,它们并没有解释如何只还原生成器。
checkpoint_dir = './training_checkpoints'
checkpoint_prefix = os.path.join(checkpoint_dir, "ckpt")
checkpoint = tf.train.Checkpoint(generator_optimizer=generator_optimizer,
discriminator_optimizer=discriminator_optimizer,
generator=generator,
discriminator=discriminator)然后用
checkpoint.restore(tf.train.latest_checkpoint(checkpoint_dir))https://stackoverflow.com/questions/56676497
复制相似问题