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.95k stars 751 forks source link

ValueError: Shape mismatch in layer #2 (named rnn_1) for weight rnn_1/lstm_cell/bias. Weight expects shape (512,). Received saved weight with shape (1024,) #274

Open alexdrymonitis opened 2 months ago

alexdrymonitis commented 2 months ago

I managed to import textgenrnn after setting up manually, because of the error here, and removing dots in from .utils import..., but when I type the following, I get the error of the subject line, which disables me from creating a textgenrnn() object:

textgen = textgenrnn()

This error is triggered by the following line in model.py.

File "/home/alex/Documents/python/TensorFlow_various/TensorFlow2/textgenrnn/textgenrnn/model.py", line 39, in textgenrnn_model
    model.load_weights(weights_path, by_name=True)

In textgenrnn.py, there's this:

        if weights_path is None:
            weights_path = resource_filename(__name__,
                                             'textgenrnn_weights.hdf5')

This tries to load the textgenrnn_weights.hdf5 file, which is a compressed type of file, that obviously contains some wrong data, compared to what the code expects. Reading this notebook, under "Training a New Model", I can't see how this can be overriden so a textgenrnn() object can be created. Any ideas?