我正在开发一个不和谐的机器人,我想要实现的功能之一是用 gpt-2-simple 库生成的文本来响应。我希望加载一个以上的模型,以便有多个模型可用于响应来自我的用户的消息。
但是,当我load_gpt2()
在第二个模型中运行该函数时出现以下错误
File "main.py", line 22, in <module>
main()
File "main.py", line 16, in main
text_events.register_Message(client)
File "U:\discord_bot\text_events\__init__.py", line 19, in register_Message
event.init()
File "U:\discord_bot\text_events\model2.py", line 20, in init
gpt2.load_gpt2(sess, run_name='model2', checkpoint_dir="characters")
File "C:\Program Files\Python36\lib\site-packages\gpt_2_simple\gpt_2.py", line 389, in load_gpt2
output = model.model(hparams=hparams, X=context, gpus=gpus)
File "C:\Program Files\Python36\lib\site-packages\gpt_2_simple\src\model.py", line 183, in model
initializer=tf.compat.v1.random_normal_initializer(stddev=0.01))
File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\python\ops\variable_scope.py", line 1500, in get_variable
aggregation=aggregation)
File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\python\ops\variable_scope.py", line 1243, in get_variable
aggregation=aggregation)
File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\python\ops\variable_scope.py", line 567, in get_variable
aggregation=aggregation)
File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\python\ops\variable_scope.py", line 519, in _true_getter
aggregation=aggregation)
File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\python\ops\variable_scope.py", line 868, in _get_single_variable
(err_msg, "".join(traceback.format_list(tb))))
ValueError: Variable model/wpe already exists, disallowed. Did you mean to set reuse=True or reuse=tf.AUTO_REUSE in VarScope? Originally defined at:
File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\python\framework\ops.py", line 1748, in __init__
self._traceback = tf_stack.extract_stack()
File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3426, in _create_op_internal
op_def=op_def)
File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\python\framework\ops.py", line 3357, in create_op
attrs, op_def, compute_device)
File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\python\framework\op_def_library.py", line 794, in _apply_op_helper
op_def=op_def)
我试图找到一种方法让 gpt2 实例在模块之间保持分离,但我找不到任何可以实现这种沙盒效果的东西,或者任何其他分离模型或其实例的建议。有没有人有任何想法?