用jupyter调试模型的时候,经常会遇到类似的错误
Variable embedding already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope?
Variable encoder/embedding does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=tf.AUTO_REUSE in VarScope?
tf创建变量主要与三个函数tf.Variable,tf.get_variable,tf.variable_scope有关
tf.variable_scope
tf.variable_scope(name, reuse)目的是创建一个变量空间,可以将之视为一个文件夹,里面储存相应在这个空间中创建的变量。
如果变量空间没有同名变量,用get_variable()必须设置reuse=False来创建一个新变量,但如果有同名变量,reuse=False会导致上面的第一

这篇博客介绍了在TensorFlow中使用变量时涉及的关键函数,包括`tf.Variable`,`tf.get_variable`和`tf.variable_scope`。通过实例展示了如何避免在变量空间中创建重复变量,强调了`reuse=tf.AUTO_REUSE`的重要性,并指出`tf.Variable`会每次都创建新的变量,而`tf.get_variable`会查找并重用已存在的同名变量。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



