LSTM多层出现的问题:MultiRNNCell出现的错误问题以及解决方案
来源:互联网 发布:淘宝满包邮在哪里设置 编辑:程序博客网 时间:2024/06/03 19:59
错误:ValueError: Attempt to reuse RNNCell <tensorflow.contrib.rnn.python.ops.core_rnn_cell_impl.GRUCell object at 0x11d32cbd0> with a different variable scope than its first use. First use of cell was with scope 'rnn/multi_rnn_cell/cell_0/gru_cell', this attempt is with scope 'rnn/multi_rnn_cell/cell_1/gru_cell'. Please create a new instance of the cell if you would like it to use a different set of weights. If before you were using: MultiRNNCell([GRUCell(...)] * num_layers), change to: MultiRNNCell([GRUCell(...) for _ in range(num_layers)]). If before you were using the same cell instance as both the forward and reverse cell of a bidirectional RNN, simply create two instances (one for forward, one for reverse). In May 2017, we will start transitioning this cell's behavior to use existing stored weights, if any, when it is called with scope=None (which can lead to silent model degradation, so this error will remain until then.)
原始代码:
from tensorflow.contrib import rnn
inputs = tf.placeholder(dtype=tf.int32, shape=[None, None], name="inputs")
keep_prob = tf.placeholder(dtype=tf.float32, name="keep_prob")
cell = rnn.GRUCell(10)
cell = rnn.DropoutWrapper(cell=cell, input_keep_prob=keep_prob)
cell = rnn.MultiRNNCell([cell for _ in range(5)], state_is_tuple=True)
outs, states = tf.nn.dynamic_rnn(cell=cell, inputs=look_up, dtype=tf.float32)
解决办法:
inputs = tf.placeholder(dtype=tf.int32, shape=[None, None], name="inputs")
keep_prob = tf.placeholder(dtype=tf.float32, name="keep_prob")
cell = rnn.MultiRNNCell([rnn.DropoutWrapper(rnn.GRUCell(10), input_keep_prob=keep_prob) for _ in range(5)] , state_is_tuple=True)
outs, states = tf.nn.dynamic_rnn(cell=cell, inputs=look_up, dtype=tf.float32)
- LSTM多层出现的问题:MultiRNNCell出现的错误问题以及解决方案
- iis 经常出现的问题以及解决方案
- 【MYSQL】PHPMYADMIN出现的问题以及解决方案
- 出现NaN问题的解决方案
- 工程make时出现"时钟错误的问题"的解决方案
- Android重新安装以及出现的一些问题和解决方案
- 编译时常出现缺少库的问题以及解决方案
- Git配置过程中出现的问题,以及解决方案
- volley+listView结合使用时出现的问题以及解决方案
- Gson解析多层嵌套的数组出现的问题
- 起动crs出现的问题以及ORA-00376错误
- baseAdapter出现IllegalStateException错误的问题,以及优化方案
- Android在ScrollView中嵌套ViewPager以及ListView的可能出现的问题以及解决方案
- Discuz!论坛出现附件问题的解决方案
- 破解XCODE4.3.2出现问题的解决方案
- Jar打包后出现问题的解决方案
- IIS出现Connections_Refused问题的解决方案
- STM8出现如下问题的解决方案
- C++中函数参数传递(值传递、指针传递,引用传递)
- 测试
- 3. Longest Substring Without Repeating Characters
- MySQL性能优化的21个最佳实践 和 mysql使用索引
- .net线程池内幕
- LSTM多层出现的问题:MultiRNNCell出现的错误问题以及解决方案
- mybatis配置文件
- 前端框架-BootStrap
- KVC 与 KVO
- 安卓HelloWorld程序创建
- IP地址和子网掩码
- 内联函数与宏
- Spring中静态方法中使用@Resource注解的变量
- gapdebug problem loading url