Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行train_lstm()时报错 #9

Open
zhouhaopku opened this issue Jul 19, 2017 · 2 comments
Open

运行train_lstm()时报错 #9

zhouhaopku opened this issue Jul 19, 2017 · 2 comments

Comments

@zhouhaopku
Copy link

Attempt to have a second RNNCell use the weights of a variable scope that already has weights: 'rnn/basic_lstm_cell'; and the cell was not constructed as BasicLSTMCell(..., reuse=True). To share the weights of an RNNCell, simply reuse it in your second calculation, or create a new one with the argument reuse=True.
我查了stackoverflow,按照上面问题将rnn.BasicLSTMCell(rnn_unit)修改成cell=rnn.BasicLSTMCell(rnn_unit, reuse=True)或者rnn.BasicLSTMCell(rnn_unit,reuse = tf.get_variable_scope().reuse)还是报错:
ValueError: Variable rnn/basic_lstm_cell/weights already exists, disallowed. Did you mean to set reuse=True in VarScope?
请问是怎么运行该代码啊?

@std-in
Copy link

std-in commented Jan 23, 2018

with tf.variable_scope('cell_def', reuse=tf.AUTO_REUSE):
    cell = tf.nn.rnn_cell.BasicLSTMCell(rnn_unit)
with tf.variable_scope('rnn_def', reuse=tf.AUTO_REUSE):
    output_rnn, final_states = tf.nn.dynamic_rnn(cell, input_rnn,
                                             initial_state=init_state,
                                             dtype=tf.float32)

@RalphWithoutMissFun
Copy link

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@std-in @RalphWithoutMissFun @zhouhaopku and others