tensorflow入门笔记二

匿名 (未验证) 提交于 2019-12-03 00:30:01
报错
ValueError: Variable hello/rnn/basic_lstm_cell/weights already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at

因为之前的cell kernel还在运行,如果使用的两个不同的cell,用variable scope指明

with tf.variable_scope('forward'):     self.lstm_fw_cell = rnn_cell.BasicLSTMCell(dim_hidden)    with tf.variable_scope('backward'):     self.lstm_bw_cell = rnn_cell.BasicLSTMCell(dim_hidden)

如果使用的是相同的cell,将cell中的reuse设为True

rnn.BasicLSTMCell(num_hidden, forget_bias=1.0, reuse = True)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!