gpt4 book ai didi

python - 值错误 : Attempt to have a second RNNCell use the weights of a variable scope that already has weights

转载 作者:太空宇宙 更新时间:2023-11-04 05:10:48 27 4
gpt4 key购买 nike

我运行了 Tensorflow 1.0 提供的 ptb_word_lm.py,但它显示了这条消息:

ValueError: Attempt to have a second RNNCell use the weights of a variable scope that already has weights: 'Model/RNN/multi_rnn_cell/cell_0/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.

然后我修改代码,将'reuse=True'添加到BasicLSTMCell,但它显示了这条消息:

ValueError: Variable Model/RNN/multi_rnn_cell/cell_0/basic_lstm_cell/weights does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=None in VarScope?

我该如何解决这个问题?

最佳答案

reuse = tf.get_variable_scope().reuse 添加到 BasicLSTMCell 对我来说没问题。

关于python - 值错误 : Attempt to have a second RNNCell use the weights of a variable scope that already has weights,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43060827/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com