我在 colab 上使用自己的数据集对 gpt-2 进行了微调,并且设法生成了文本,但是当我下载模型并尝试在 spyder 中生成文本时,我收到了这个 ValueError: Trying to share variable model/wpe, but specified shape (1024, 1280) 并找到形状 (1024, 768)。
这是我运行的代码` 将 gpt_2_simple 导入为 gpt2
sess = gpt2.start_tf_sess()
gpt2.load_gpt2(sess, run_name='path to model file')
gpt2.generate(sess,
temperature=0.7,
top_k=40,
nsamples=1,
batch_size=1,
length=200,
sample_delim=''
)`
这里是错误:
` 文件“”,第 11 行,在 sample_delim=''
文件“C:\Users\Wahiba\anaconda3\envs\PythonKerasCPU\lib\site-packages\gpt_2_simple\gpt_2.py”,第459行,生成 温度=温度,top_k=top_k,top_p=top_p
文件“C:\Users\Wahiba\anaconda3\envs\PythonKerasCPU\lib\site-packages\gpt_2_simple\src\sample.py”,第67行,在sample_sequence中 context_output = step(hparams, context[:, :-1])
文件“C:\Users\Wahiba\anaconda3\envs\PythonKerasCPU\lib\site-packages\gpt_2_simple\src\sample.py”,第52行,步骤 过去=过去,重用=tf.compat.v1.AUTO_REUSE)
文件“C:\Users\Wahiba\anaconda3\envs\PythonKerasCPU\lib\site-packages\gpt_2_simple\src\model.py”,第183行,在模型中 初始值设定项=tf.compat.v1.random_normal_initializer(stddev=0.01))
文件“C:\Users\Wahiba\anaconda3\envs\PythonKerasCPU\lib\site-packages\tensorflow_core\python\ops\variable_scope.py”,第 1501 行,在 get_variable 中 聚合=聚合)
文件“C:\Users\Wahiba\anaconda3\envs\PythonKerasCPU\lib\site-packages\tensorflow_core\python\ops\variable_scope.py”,第 1244 行,在 get_variable 中 聚合=聚合)
文件“C:\Users\Wahiba\anaconda3\envs\PythonKerasCPU\lib\site-packages\tensorflow_core\python\ops\variable_scope.py”,第 567 行,在 get_variable 中 聚合=聚合)
文件“C:\Users\Wahiba\anaconda3\envs\PythonKerasCPU\lib\site-packages\tensorflow_core\python\ops\variable_scope.py”,第519行,_true_getter 聚合=聚合)
文件“C:\Users\Wahiba\anaconda3\envs\PythonKerasCPU\lib\site-packages\tensorflow_core\python\ops\variable_scope.py”,第 874 行,在 _get_single_variable (名称,形状,found_var.get_shape()))
ValueError: 试图共享变量模型/wpe,但指定形状 (1024, 1280) 并找到形状 (1024, 768)。 `
enter image description here enter image description here
我做错了什么?