gpt4 book ai didi

classification - ValueError : Variable Embedding already exists, 不允许。您的意思是在 VarScope 中设置重用 = True 吗?最初定义

转载 作者:行者123 更新时间:2023-12-04 06:42:45 25 4
gpt4 key购买 nike

基于此 github 链接 https://github.com/brightmart/text_classification/tree/master/a03_TextRNN当我运行时 训练 a03_TextRNN google_news_wor22vec.bin 和一个 带有我的文档 + 标签的文本文件 ,我有这些错误:

我该如何解决这个问题?

error image

    Traceback (most recent call last):
File "p8_TextRNN_train.py", line 184, in <module>
tf.app.run()
File "/home/eslami/anaconda3/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "p8_TextRNN_train.py", line 68, in main
vocab_size, FLAGS.embed_size, FLAGS.is_training)
File "/home/eslami/Downloads/all-kind-text_classification-master/a03_TextRNN/p8_TextRNN_model.py", line 33, in init
self.instantiate_weights()
File "/home/eslami/Downloads/all-kind-text_classification-master/a03_TextRNN/p8_TextRNN_model.py", line 45, in instantiate_weights
self.Embedding = tf.get_variable("Embedding",shape=[self.vocab_size, self.embed_size],initializer=self.initializer) #[vocab_size,embed_size] tf.random_uniform([self.vocab_size, self.embed_size],-1.0,1.0)
File "/home/eslami/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/variable_scope.py", line 1065, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "/home/eslami/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/variable_scope.py", line 962, in get_variable
use_resource=use_resource, custom_getter=custom_getter)
File "/home/eslami/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/variable_scope.py", line 367, in get_variable
validate_shape=validate_shape, use_resource=use_resource)
File "/home/eslami/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/variable_scope.py", line 352, in _true_getter
use_resource=use_resource)
File "/home/eslami/anaconda3/lib/python3.5/site-packages/tensorflow/python/ops/variable_scope.py", line 664, in _get_single_variable
name, "".join(traceback.format_list(tb))))

ValueError: Variable Embedding already exists, disallowed. Did you mean to set reuse=True in VarScope? Originally defined at:
File "/home/eslami/Downloads/all-kind-text_classification-master/a03_TextRNN/p8_TextRNN_model.py", line 45, in instantiate_weights
self.Embedding = tf.get_variable("Embedding",shape=[self.vocab_size, self.embed_size],initializer=self.initializer) #[vocab_size,embed_size] tf.random_uniform([self.vocab_size, self.embed_size],-1.0,1.0)
File "/home/eslami/Downloads/all-kind-text_classification-master/a03_TextRNN/p8_TextRNN_model.py", line 33, in init
self.instantiate_weights()
File "/home/eslami/Downloads/all-kind-text_classification-master/a03_TextRNN/p8_TextRNN_model.py", line 123, in test
textRNN=TextRNN(num_classes, learning_rate, batch_size, decay_steps, decay_rate,sequence_length,vocab_size,embed_size,is_training)

最佳答案

这已经很晚了,但是我发现您的帖子是因为我正在寻找解决类似问题的方法。如果其他人在这里找到了方法,请在模型的开头添加此代码将解决问题:

tf.reset_default_graph()

关于classification - ValueError : Variable Embedding already exists, 不允许。您的意思是在 VarScope 中设置重用 = True 吗?最初定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47717317/

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