Tensorflow 2.0 compat保护程序未找到Tensorflow 1.0中存在的变量

2024-07-02 04:18:03 发布

您现在位置:Python中文网/ 问答频道 /正文

with tf.compat.v1.Session() as sess:
    model = Model(reversed_dict, article_max_len, summary_max_len, args)
    sess.run(tf.compat.v1.global_variables_initializer())
    saver = tf.compat.v1.train.Saver(tf.compat.v1.global_variables())

我得到这个错误:


---------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-19-42e9e3d94e79> in <module>
     37     model = Model(reversed_dict, article_max_len, summary_max_len, args)
     38     sess.run(tf.compat.v1.global_variables_initializer())
---> 39     saver = tf.compat.v1.train.Saver(tf.compat.v1.global_variables())

ValueError: No variables to save

我想通过初始化全局变量来创建“要保存的变量”??是否有从tf1到tf2.0的中断

背景:这是tensorflow 1.0代码,我将其升级为2.0


Tags: modellentfarticleargsvariablessummaryglobal

热门问题