I have finetuned gpt-2 with my own dataset on colab and I managed to generate text but when I downloaded my model and tried to generate text in spyder I got this ValueError: Trying to share variable model/wpe, but specified shape (1024, 1280) and found shape (1024, 768).
Here is the code I run `
import gpt_2_simple as 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=''
)`
Here is the error:
`
File "", line 11, in
sample_delim=''
File "C:UsersWahibaanaconda3envsPythonKerasCPUlibsite-packagesgpt_2_simplegpt_2.py", line 459, in generate
temperature=temperature, top_k=top_k, top_p=top_p
File "C:UsersWahibaanaconda3envsPythonKerasCPUlibsite-packagesgpt_2_simplesrcsample.py", line 67, in sample_sequence
context_output = step(hparams, context[:, :-1])
File "C:UsersWahibaanaconda3envsPythonKerasCPUlibsite-packagesgpt_2_simplesrcsample.py", line 52, in step
past=past, reuse=tf.compat.v1.AUTO_REUSE)
File "C:UsersWahibaanaconda3envsPythonKerasCPUlibsite-packagesgpt_2_simplesrcmodel.py", line 183, in model
initializer=tf.compat.v1.random_normal_initializer(stddev=0.01))
File "C:UsersWahibaanaconda3envsPythonKerasCPUlibsite-packagesensorflow_corepythonopsvariable_scope.py", line 1501, in get_variable
aggregation=aggregation)
File "C:UsersWahibaanaconda3envsPythonKerasCPUlibsite-packagesensorflow_corepythonopsvariable_scope.py", line 1244, in get_variable
aggregation=aggregation)
File "C:UsersWahibaanaconda3envsPythonKerasCPUlibsite-packagesensorflow_corepythonopsvariable_scope.py", line 567, in get_variable
aggregation=aggregation)
File "C:UsersWahibaanaconda3envsPythonKerasCPUlibsite-packagesensorflow_corepythonopsvariable_scope.py", line 519, in _true_getter
aggregation=aggregation)
File "C:UsersWahibaanaconda3envsPythonKerasCPUlibsite-packagesensorflow_corepythonopsvariable_scope.py", line 874, in _get_single_variable
(name, shape, found_var.get_shape()))
ValueError: Trying to share variable model/wpe, but specified shape (1024, 1280) and found shape (1024, 768). `
enter image description here
enter image description here
What am I doing wrong?
question from:
https://stackoverflow.com/questions/65934468/incompatible-shape-error-in-tensorflow-when-i-try-to-run-generate-function-of-gp