Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError(Shape error) while running predict.py iam getting this error. Anyone can help me,Thanks in advance #36

Open
naganikshith04 opened this issue Feb 26, 2020 · 15 comments

Comments

@naganikshith04
Copy link

C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:469: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:470: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:471: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:472: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:473: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_qint32 = np.dtype([("qint32", np.int32, 1)])
C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:476: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
np_resource = np.dtype([("resource", np.ubyte, 1)])
C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\h5py_init
.py:36: FutureWarning: Conversion of the second argument of issubdtype from float to np.floating is deprecated. In future, it will be treated as np.float64 == np.dtype(float).type.
from ._conv import register_converters as _register_converters
Using TensorFlow backend.
Traceback (most recent call last):
File "C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 686, in _call_cpp_shape_fn_impl
input_tensors_as_shapes, status)
File "C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 473, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimension 1 in both shapes must be equal, but are 358 and 279 for 'Assign_19' (op: 'Assign') with input shapes: [256,358], [256,279].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "predict.py", line 148, in
generate()
File "predict.py", line 30, in generate
model = create_network(normalized_input, n_vocab)
File "predict.py", line 84, in create_network
model.load_weights('weights.hdf5')
File "C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\keras_impl\keras\models.py", line 693, in load_weights
topology.load_weights_from_hdf5_group(f, layers)
File "C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\keras_impl\keras\engine\topology.py", line 1486, in load_weights_from_hdf5_group
K.batch_set_value(weight_value_tuples)
File "C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\keras_impl\keras\backend.py", line 2401, in batch_set_value
assign_op = x.assign(assign_placeholder)
File "C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\variables.py", line 573, in assign
return state_ops.assign(self._variable, value, use_locking=use_locking)
File "C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\state_ops.py", line 276, in assign
validate_shape=validate_shape)
File "C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\gen_state_ops.py", line 56, in assign
use_locking=use_locking, name=name)
File "C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 2958, in create_op
set_shapes_for_outputs(ret)
File "C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 2209, in set_shapes_for_outputs
shapes = shape_func(op)
File "C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\ops.py", line 2159, in call_with_requiring
return call_cpp_shape_fn(op, require_shape_fn=True)
File "C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 627, in call_cpp_shape_fn
require_shape_fn)
File "C:\Users\nagan\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\common_shapes.py", line 691, in _call_cpp_shape_fn_impl
raise ValueError(err.message)
ValueError: Dimension 1 in both shapes must be equal, but are 358 and 279 for 'Assign_19' (op: 'Assign') with input shapes: [256,358], [256,279].

@zsheill7
Copy link

hey! i'm having the same problem - did you happen to find a solution?
thanks!

@naganikshith04
Copy link
Author

@zsheill7 Sorry , but i was unable to get a solution.Sed:(

@Skuldur
Copy link
Owner

Skuldur commented Apr 22, 2020

Hi,

This is due to inconsistencies between the model and the data you're using. If you make changes to the data then you have to train the model again so that you can generate songs.

@naganikshith04
Copy link
Author

@Skuldur that means we need to train the model again?thank you.

@Skuldur
Copy link
Owner

Skuldur commented Apr 22, 2020

Yes, you need to train the model again using your data and then use the weights file generated by training the model to generate sequences of notes. :)

The weights I have included in the repository only works with the data that's provided in the repository.

@naganikshith04
Copy link
Author

@Skuldur i was usung your weights and data you have provided ...but this error has arised.

@Skuldur
Copy link
Owner

Skuldur commented Apr 22, 2020

Okay, I'll look into this after work today. Finally have some time due to social isolation.

@naganikshith04
Copy link
Author

@Skuldur Thankyou so much!

@Skuldur
Copy link
Owner

Skuldur commented Apr 24, 2020

Hi,

I just pulled the repository into a clean directory and running predict.py worked perfectly. Are you certain that you didn't make any changes to any file after clone the repository?

@naganikshith04
Copy link
Author

@Skuldur Thankyou very much. I will again clone the repo and try it again sorry man! :).

@SutirthaChakraborty
Copy link

image

Still facing the issue, any clue? If I run a few epochs it works, any clue?

@Skuldur
Copy link
Owner

Skuldur commented Aug 6, 2020

If you change the dataset and the data/notes file then you have to retrain the model because the amount of different notes and chords will differ from what the model is expecting.

@shaswat-du
Copy link

Hi @Skuldur. The Weights doesn't fit the model used in the predict.py. It has nothing to do with the data set. Could you share the model you used for training? That'll be very helpful. Thanks.

@Skuldur
Copy link
Owner

Skuldur commented Aug 27, 2020

Hi,

I just pulled the repository into a clean environment on my work computer and

  1. Running predict.py directly worked perfectly.
  2. Training a model using lstm.py and using the weights from that model in predict.py worked perfectly.

Are you certain that you didn't make any changes to any file after clone the repository? Predict.py uses data/notes to get information on dimensions. If you run lstm.py, that file gets overwritten with information corresponding to your current dataset.

@trulee0913
Copy link

I think it is not a problem of coding. It is the problem of communication.
For these who get the value error, simple open predict.py and make following changes should help.
After we train the model, we will get new weights file called weights improvement or something like that.
Simple replace the name of this file to weights.hdf5 should solve the issue. Have a nice music. This programe is awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants