【发布时间】:2019-11-18 18:25:13
【问题描述】:
https://www.tensorflow.org/beta/tutorials/generative/dcgan 我正在关注 DCGAN 的本教程,并尝试从我保存的检查点恢复模型。但是当我尝试加载模型时,它给了我一个错误:
AssertionError: Nothing except the root object matched a checkpointed value. Typically this means that the checkpoint does not match the Python program. The following objects have no matching checkpointed value: [<tensorflow.python.keras.layers.advanced_activations.LeakyReLU object at 0x7f05b545fc88>, <tf.Variable 'conv2d_transpose_5/kernel:0' shape=(3, 3, 1, 64) dtype=float32, numpy=.......
我试图通过只保留生成器部分来修改检查点,因为这就是我需要的全部内容。在那之后,我做
latest = tf.train.latest_checkpoint(checkpoint_dir)
gen_mod = make_generator_model() #This is already defined in the code
gen_mod.load_weights(latest)
sample = gen_mod(noise,training=False)
这给了我错误。有没有办法只加载生成器部分? 我想要的是能够使用生成器模型从给定的检查点生成图像。
【问题讨论】:
-
有什么解决办法吗?我无法从使用 c api 生成的检查点将权重加载到 keras 中
-
首先我很抱歉,因为我应该用我找到的“解决方案”更新帖子。我的问题是我使用的是子类模型,它们是一个相当棘手的集合。在此处 (tensorflow.org/beta/guide/keras/saving_and_serializing) 阅读有关保存和重新加载模型的更多信息。也许你会发现一些东西。再次抱歉帮不上忙。
-
是的,我对这个 stackoverflow.com/questions/57993832/… 感到很疯狂,我可以完全使用 C api,但是一旦我尝试在 python 中使用这些权重,我就可以让它们成功加载,不管加载方式
标签: tensorflow2.0 generative-adversarial-network