Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: Shapes (4, 128, 128) and () are incompatible

See original GitHub issue


I know that the authors of this project have moved on, but I am still curious if anyone has ran into a similar issue regarding the shapes for the LSTM network.

I am only attempting to train the single-speaker.

First, I had to fork the project and fix the Makefile so that it pulls the VCTK-Corpus dataset from a different source (

Second, I had to downgrade joblib to 0.11 due to a bug in the most recent Python2.7-compatible version.

This allowed me to download, make, and perform the downsampling on the dataset using the following parameters (the default parameters in the Makefile would simply not work for me and produce empty .h5 files):

sca = 4
sr = 16000

tr_dim = 8192
tr_str = 4096

va_dim = 8192
va_str = 4096

Now, whenever I am trying to train using the following (ignore the $output_name variables):

!python train 
  --train ../data/vctk/speaker1/$train_output_name
  --val ../data/vctk/speaker1/$val_output_name -e 120 
  --batch-size 64 
  --lr 3e-4 
  --logname singlespeaker 
  --model audiotfilm 
  --r 4 
  --layers 4 
  --piano false
  --pool_size 8 
  --strides 8 
  --full true

I receive this error:

/content/gdrive/My Drive/audio-super-res/src
Using TensorFlow backend.
List of arrays in input file: [u'data', u'label']
Shape of X: (3328, 8192, 1)
Shape of Y: (3328, 8192, 1)
List of arrays in input file: [u'data', u'label']
Shape of X: (384, 8192, 1)
Shape of Y: (384, 8192, 1)
building model...
WARNING:tensorflow:From /usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
Traceback (most recent call last):
  File "", line 172, in <module>
  File "", line 169, in main
  File "", line 119, in train
    model = get_model(args, n_dim, r, from_ckpt=False, train=True)
  File "", line 155, in get_model
    strides=args.strides, opt_params=opt_params, log_prefix=args.logname)  
  File "/content/gdrive/My Drive/audio-super-res/src/models/", line 29, in __init__
    opt_params=opt_params, log_prefix=log_prefix)
  File "/content/gdrive/My Drive/audio-super-res/src/models/", line 48, in __init__
    self.predictions = self.create_model(n_dim, r)
  File "/content/gdrive/My Drive/audio-super-res/src/models/", line 95, in create_model
    x_norm = _make_normalizer(x, nf, nb)
  File "/content/gdrive/My Drive/audio-super-res/src/models/", line 60, in _make_normalizer
    x_rnn = LSTM(output_dim = n_filters, return_sequences = True)(x_in_down)
  File "/usr/local/lib/python2.7/dist-packages/keras/engine/", line 546, in __call__[0])
  File "/usr/local/lib/python2.7/dist-packages/keras/layers/", line 784, in build
    self.W = K.concatenate([self.W_i, self.W_f, self.W_c, self.W_o])
  File "/usr/local/lib/python2.7/dist-packages/keras/backend/", line 1427, in concatenate
    return tf.concat(axis, [to_dense(x) for x in tensors])
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/util/", line 180, in wrapper
    return target(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/", line 1254, in concat
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/", line 1023, in assert_is_compatible_with
    raise ValueError("Shapes %s and %s are incompatible" % (self, other))
ValueError: Shapes (4, 128, 128) and () are incompatible

Anyone see something like this before? Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

Lootwigcommented, Apr 21, 2021

Awesome, feel free to close the issue

Sawyerbcommented, Apr 21, 2021

Thanks for the suggestion! I’ve added a requirements.txt. I’ve also upgraded to librosa 0.8.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Shapes (None,128128) and (None, 4) are incompatible
I am trying to perform CNN on my dataset. I came across the below error ValueError: Shapes (None, 128, 128) and (None, 4)...
Read more >
ValueError: Shapes (None, 128, 18) and ...
I think that your x , y arguments to are inconsistent: x is a list, y -s a numpy array. Try:
Read more >
ValueError: Shapes (None, 1) and (None, 50) are ...
I was training a CNN model (transfer learning). While compiling, I got the following error. ValueError: Shapes (None, 1) and (None, 50) are...
Read more >
ValueError: Shapes (None, 1) and (None, 4) are incompatible
Tensorflow Transfer Learning (VGG16) Error: ValueError: Shapes (None, 1) and (None, 4) are incompatible. Hello! So I am trying to create a ...
Read more >
Could you help me solve this error - General Discussion
ValueError : Shapes (None, 1) and (None, 10) are incompatible I use ... metrics=['accuracy']),y_train, batch_size=128, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found