ValueError: Variable rnn/basic_lstm_cell/kernel already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at:
问题
ValueError: Variable rnn/basic_lstm_cell/kernel already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at:
原因
调用了两次RNN网络,在第二次调用的时候报了上面这个错误。主要是因为第二次的变量名和第一次的变量名一样,导致了变量命名相同的冲突。在Tensorflow中有两种方法生成变量variable,tf.get_variable()和tf.Variable()。在tf.AUTO_REUSEtf.name_scope()的框架下使用这两种方法,使用tf.Variable(),尽管name一样,但为了不重复变量名,Tensorflow输出的变量名并不一样,所以本质上是不一样的变量;使用tf.get_variable()定义的变量虽然不会被tf.name_scope()中的名字影响,但在未指定共享变量时,如果重名了会报错。要实现变量共享,可以使用tf.variable_scope(reuse=)创建具有相同名称的作用域。
# 出错代码
with tf.name_scope("fw_side"): # 改成
with tf.name_scope("fw_side"), tf.variable_scope("fw_side", reuse=tf.AUTO_REUSE):
改了之后,在第二次调用RNN时就不会报错了。
详情了解:https://morvanzhou.github.io/tutorials/machine-learning/tensorflow/5-12-scope/
ValueError: Variable rnn/basic_lstm_cell/kernel already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at:的更多相关文章
- tensoflow模型中提示:ValueError: Variable rnn/basic_rnn_cell/kernel already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? 解决办法
在利用tensorflow框架进行模型训练的时候,有时我们需要多次训练对结果求均值来得到一个均衡的评测结论.比如训练十次求平均值.但是tf的本质就是图,当变量第一次定义使用后,第二次再使用就是提示: ...
- ValueError: Variable conv1/weights already exists.
跑TensorFlow程序的过程中出现了错误,解决之后再次跑时,报如下错误: ValueError: Variable conv1/weights already exists, 原因: 这是因为我在 ...
- asp.net core 3.1 中Synchronous operations are disallowed. Call FlushAsync or set AllowSynchronousIO to true instead
在Action中解决措施: var syncIOFeature = HttpContext.Features.Get<IHttpBodyControlFeature>(); if (syn ...
- tensorflow(4)踩过的一些坑
版本问题 1.1 版本的一个BUG ValueError: Variable rnn/basic_lstm_cell/weights already exists, disallowed. 结合这个文 ...
- TensorFlow入门(四) name / variable_scope 的使
name/variable_scope 的作用 欢迎转载,但请务必注明原文出处及作者信息. @author: huangyongye @creat_date: 2017-03-08 refer to: ...
- 5 TensorFlow入门笔记之RNN实现手写数字识别
------------------------------------ 写在开头:此文参照莫烦python教程(墙裂推荐!!!) ---------------------------------- ...
- tensorflow中的name_scope, variable_scope
在训练深度网络时,为了减少需要训练参数的个数(比如LSTM模型),或者是多机多卡并行化训练大数据.大模型等情况时,往往就需要共享变量.另外一方面是当一个深度学习模型变得非常复杂的时候,往往存在大量的变 ...
- tf之变量与作用域
生成变量 tensorflow生成变量有两种方式,Variable 和 get_variable Variable(initial_value=None, trainable=True, collec ...
- tf.variable_scope()和tf.name_scope()
1.tf.variable_scope 功能:tf.variable_scope可以让不同命名空间中的变量取相同的名字,无论tf.get_variable或者tf.Variable生成的变量 Tens ...
随机推荐
- Scrapy Selectors 选择器
0. 1.参考 <用Python写网络爬虫>——2.2 三种网页抓取方法 re / lxml / BeautifulSoup 需要注意的是,lxml在内部实现中,实际上是将CSS选择器转 ...
- Excel 转为 MySQL 语句
一.方法 一.假设你的表格有A.B.C三列数据,希望导入到你的数据库中表格table,对应的字段分别是col1.col2.col3 二.在你的表格中增加一列,利用excel的公式自动生成sql语句,具 ...
- H5唤醒app,不完全兼容
---ps---最近新发现一个开源的H5唤醒app的库:建议使用第三方开源库https://github.com/suanmei/callapp-lib实现:或者极光魔链(后期可能会收费)https: ...
- Hexo主题yilia增加gitalk评论插件
虽然gitment可以实现评论功能,但是适配方面做的并不好,这里借用GitHub上的gitalk项目用来优化个人博客的评论功能 下面记录自己从gitment到gitalk的替换过程: 1.在layou ...
- mysql 正则表达式问号
MySQL 中,用正则表达式匹配?,需要使用两个转义字符 \\? 因使用一个被坑了很久.
- linux(debian) arm-linux-g++ v4.5.1交叉编译 embedded arm 版本的QtWebkit (browser) 使用qt 4.8.6 版本 以及x64上编译qt
最近需要做一个项目 在arm 架构的linux下 没有桌面环境的情况下拉起 有界面的浏览器使用. 考虑用qt 的界面和 qtwebikt 的库去实现这一系列操作. 本文参考: Qt移植到ARM Lin ...
- maven deploy Return code is: 400, ReasonPhrase: Bad Request.
最近在自己本地deploy jar 到本地 nexus的时候,报错 Return code is: 400, ReasonPhrase: Bad Request. 解决思路: 1.查看maven pr ...
- 8. 环境变量_数据库_mongoose的基本使用_模型对象的CRUD
1. 环境变量 系统环境(cmd)使用的变量/命令 能够让我们在cmd环境下运行指定的程序 用户环境变量 path(我们一般设置这个) 系统环境变量 path 过程: 当我们在cmd中输入一个指令 先 ...
- [LeetCode] Linked List Components 链表组件
We are given head, the head node of a linked list containing unique integer values. We are also give ...
- [LeetCode] Minimum Swaps To Make Sequences Increasing 使得序列递增的最小交换
We have two integer sequences A and B of the same non-zero length. We are allowed to swap elements A ...