Skuldur / Classical-Piano-Composer

MIT License
602 stars 318 forks source link

unable to load weights from weights.hdf5 #10

Open govardhangdg opened 5 years ago

govardhangdg commented 5 years ago

ValueError: Dimension 1 in both shapes must be equal, but are 1024 and 2048. Shapes are [1,1024] and [1,2048]. for 'Assign' (op: 'Assign') with input shapes: [1,1024], [1,2048]. is the error being shown

Utayaki commented 5 years ago

Did you change the number in model.add(LSTM(512))?

Probably, you have different numbers, in the place of 512, in predict.py and lstm.py.

Does they are the same?

winnie334 commented 5 years ago

I might have found a solution.

Whenever your network finishes an epoch, it saves it weights to a new file, called something like 'weights-improvement-11-2.9103-bigger.hdf5'. These weights are what you want to generate a new midi. The file predict.py however, always loads in the same weights: Line 70: model.load_weights('weights.hdf5'). That is why you're getting an error.

You should be able to run the network with any number of nodes, be it 512, 256 or even 2048. You have to load in the correct weights for that, however. What I did as a temporary solution is copy the name of the newly-generated weight file, and paste it into line 70 before generating a new midi. This works, but it isn't exactly elegant. Hopefully there'll be some kind of fix soon.

beatelite commented 5 years ago

@winnie334's fix worked for me. Nice!