minimaxir / textgenrnn

Easily train your own text-generating neural network of any size and complexity on any text dataset with a few lines of code.
Other
4.94k stars 754 forks source link

ValueError: Layer #1 (named "embedding"), weight <tf.Variable 'embedding_4/embeddings:0' shape=(209, 100) dtype=float32_ref> has shape (209, 100), but the saved weight has shape (465, 100). #136

Open WYAOBO opened 5 years ago

WYAOBO commented 5 years ago

mycode: from textgenrnn import textgenrnn textgen = textgenrnn() textgen.train_from_file('hacker-news- 2000.txt ',num_epochs = 1) textgen.generate() textgen.save('trainedRnn.hdf5')

error:ValueError: Layer #1 (named "embedding"), weight <tf.Variable 'embedding_4/embeddings:0' shape=(209, 100) dtype=float32_ref> has shape (209, 100), but the saved weight has shape (465, 100).

why?

samgrat commented 5 years ago

Solution was posted by ihavetoomanyquestions, worked for me

'Sorry for spamming, the problem was fixed after I initialized the model like that (with vocab & config files):

textgen = textgenrnn(weights_path='weights.hdf5', vocab_path='vocab.json', config_path='config.json')'

https://github.com/minimaxir/textgenrnn/issues/31

goshawk22 commented 4 years ago

You have to put the correct path to your weights, vocab and config. Use the 'ls' command to find these.