Skuldur / Classical-Piano-Composer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unable to load weights from weights.hdf5

govardhangdg opened this issue · comments

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

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?

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.

@winnie334's fix worked for me. Nice!