Grzego / handwriting-generation

Implementation of handwriting generation with use of recurrent neural networks in tensorflow. Based on Alex Graves paper (https://arxiv.org/abs/1308.0850).
MIT License
531 stars 107 forks source link

Issue in running the train.py file #28

Closed pcsingh closed 3 years ago

pcsingh commented 3 years ago

Hi @Grzego,

I am trying to run the train.py (python train.py) file on the same IAM Online handwriting dataset. But getting some error (using tf 1.15)

image

Thank you for your help!!

pcsingh commented 3 years ago

I found the issue is coming through this line L174 of the train.py file.

When I remove the initial_state argument (optional) and add the dtype then the epochs started running but after the training, the trained model is not performing.

pcsingh commented 3 years ago

Hi @Grzego,

I hope you are doing well!

I figure out the issue and resolved it (using TF 1.15.2 environment). The error on the above screenshot shows the shape of the window variable that is coming from the WindowLayer line L54 in the train.py file.

Actually, the tf.matmul function gives the different format of shaped output for different batch_size. For (64, 1, None) (None, None, 80) gives (64, 1, 80) For (1, 1, None) (None, None, 80) gives (None, 1, 80) it should be (1, 1, 80) Here, 64 and 1 are the batch_size.

So, what I did is changed the shape of output after tf.matmul to (1, 1, 80) if it is (None, 1, 80)

window = tf.matmul(phi, self.sequence)
if window.get_shape().as_list() == [None, 1, 80]:
    window = tf.reshape(window, (1, 1, 80))

This resolved the issue, I faced in training the model. However thank you for this repository, I got many things to learn from it.