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

tensorflow.python.framework.errors_impl.InvalidArgumentError: All dimensions except 2 must match. Input 1 has shape [128 32 512] and doesn't match input 0 with shape [128 16 512] #38

Closed
xiaojian10 opened this issue Jun 7, 2021 · 6 comments

Comments

@xiaojian10
Copy link

Hi!
I recently encountered a problem as follows:
List of arrays in input file: ['data', 'label']
Shape of X: (66688, 8192, 1)
Shape of Y: (66688, 8192, 1)
List of arrays in input file: ['data', 'label']
Shape of X: (5248, 8192, 1)
Shape of Y: (5248, 8192, 1)
audiotfilm
building model...
D-Block: (None, None, 128)
D-Block: (None, None, 256)
D-Block: (None, None, 512)
D-Block: (None, None, 512)
U-Block: (None, None, 1024)
U-Block: (None, None, 1024)
U-Block: (None, None, 512)
U-Block: (None, None, 256)
creating train_op with params: {'alg': 'adam', 'lr': 0.001, 'b1': 0.9, 'b2': 0.999, 'batch_size': 128, 'layers': 4}
WARNING:tensorflow:From /root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/util/tf_should_use.py:247: initialize_all_variables (from tensorflow.python.ops.variables) is deprecated and will be removed after 2017-03-02.
Instructions for updating:
Use tf.global_variables_initializer instead.
Parameters: 68221186
Traceback (most recent call last):
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1375, in _do_call
return fn(*args)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1360, in _run_fn
target_list, run_metadata)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1453, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: All dimensions except 2 must match. Input 1 has shape [128 32 512] and doesn't match input 0 with shape [128 16 512].
[[{{node gradients/generator/upsc_conv3/concatenate/concat_grad/ConcatOffset}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "run.py", line 176, in
main()
File "run.py", line 173, in main
args.func(args)
File "run.py", line 125, in train
model.fit(X_train, Y_train, X_val, Y_val, n_epoch=args.epochs, r=args.r, speaker=args.speaker, grocery=args.grocery, piano=args.piano, calc_full_snr = full)
File "/root/xiaojian/two/audio-super-res-master/src/models/model.py", line 249, in fit
tr_objective = self.train(feed_dict)
File "/root/xiaojian/two/audio-super-res-master/src/models/model.py", line 324, in train
[self.train_op, self.loss], feed_dict=feed_dict)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 968, in run
run_metadata_ptr)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1191, in _run
feed_dict_tensor, options, run_metadata)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1369, in _do_run
run_metadata)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1394, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: All dimensions except 2 must match. Input 1 has shape [128 32 512] and doesn't match input 0 with shape [128 16 512].
[[node gradients/generator/upsc_conv3/concatenate/concat_grad/ConcatOffset (defined at /root/xiaojian/two/audio-super-res-master/src/models/model.py:151) ]]
image

Is this problem caused by the environment configuration, or is it?

@xiaojian10
Copy link
Author

Original stack trace for 'gradients/generator/upsc_conv3/concatenate/concat_grad/ConcatOffset':
File "run.py", line 176, in
main()
File "run.py", line 173, in main
args.func(args)
File "run.py", line 123, in train
model = get_model(args, n_dim, r, from_ckpt=False, train=True)
File "run.py", line 159, in get_model
strides=args.strides, opt_params=opt_params, log_prefix=args.logname)
File "/root/xiaojian/two/audio-super-res-master/src/models/audiotfilm.py", line 31, in init
opt_params=opt_params, log_prefix=log_prefix)
File "/root/xiaojian/two/audio-super-res-master/src/models/model.py", line 55, in init
self.train_op = self.create_train_op(X, Y, alpha)
File "/root/xiaojian/two/audio-super-res-master/src/models/model.py", line 91, in create_train_op
grads = self.create_gradients(self.loss, params)
File "/root/xiaojian/two/audio-super-res-master/src/models/model.py", line 151, in create_gradients
gv = self.optimizer.compute_gradients(loss, params)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/training/optimizer.py", line 512, in compute_gradients
colocate_gradients_with_ops=colocate_gradients_with_ops)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/ops/gradients_impl.py", line 172, in gradients
unconnected_gradients)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/ops/gradients_util.py", line 684, in _GradientsHelper
lambda: grad_fn(op, *out_grads))
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/ops/gradients_util.py", line 340, in _MaybeCompile
return grad_fn() # Exit early
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/ops/gradients_util.py", line 684, in
lambda: grad_fn(op, *out_grads))
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/ops/array_grad.py", line 229, in _ConcatGradV2
op, grad, start_value_index=0, end_value_index=-1, dim_index=-1)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/ops/array_grad.py", line 155, in _ConcatGradHelper
offset = gen_array_ops.concat_offset(non_neg_concat_dim, sizes)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 1140, in concat_offset
"ConcatOffset", concat_dim=concat_dim, shape=shape, name=name)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py", line 750, in _apply_op_helper
attrs=attr_protos, op_def=op_def)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3536, in _create_op_internal
op_def=op_def)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1990, in init
self._traceback = tf_stack.extract_stack()

...which was originally created as op 'generator/upsc_conv3/concatenate/concat', defined at:
File "run.py", line 176, in
main()
[elided 3 identical lines from previous traceback]
File "/root/xiaojian/two/audio-super-res-master/src/models/audiotfilm.py", line 31, in init
opt_params=opt_params, log_prefix=log_prefix)
File "/root/xiaojian/two/audio-super-res-master/src/models/model.py", line 48, in init
self.predictions = self.create_model(n_dim, r)
File "/root/xiaojian/two/audio-super-res-master/src/models/audiotfilm.py", line 135, in create_model
x = Concatenate()([x, l_in])
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer_v1.py", line 786, in call
outputs = call_fn(cast_inputs, *args, **kwargs)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/keras/layers/merge.py", line 183, in call
return self._merge_function(inputs)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/keras/layers/merge.py", line 522, in _merge_function
return K.concatenate(inputs, axis=self.axis)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py", line 201, in wrapper
return target(*args, **kwargs)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/keras/backend.py", line 2989, in concatenate
return array_ops.concat([to_dense(x) for x in tensors], axis)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py", line 201, in wrapper
return target(*args, **kwargs)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py", line 1677, in concat
return gen_array_ops.concat_v2(values=values, axis=axis, name=name)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 1208, in concat_v2
"ConcatV2", values=values, axis=axis, name=name)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py", line 750, in _apply_op_helper
attrs=attr_protos, op_def=op_def)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3536, in _create_op_internal
op_def=op_def)
File "/root/anaconda3/envs/xiaojian/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1990, in init
self._traceback = tf_stack.extract_stack()

@Sawyerb
Copy link
Collaborator

Sawyerb commented Jun 7, 2021

What's the full command you're using to train? I can't reproduce the issue on my end. What are you setting as the pool size and stride?

@xiaojian10
Copy link
Author

Thank you very much for your reply, my parameter settings are as follows:

The .h5 file is generated by executing Makefile, and the detailed parameters are:
image

Second, in the training model, my input is:
image

The remaining parameters are the default parameters in run.py!

@xiaojian10
Copy link
Author

If the .h5 file obtained by using the default parameter settings in the Makefile, the following problems will occur:
image

image

@Sawyerb
Copy link
Collaborator

Sawyerb commented Jun 29, 2021

Sorry for the delayed response. Rather than using the default parameters, use the following:

  --train ../data/vctk/speaker1/vctk-speaker1-train.4.16000.8192.4096.h5 \
  --val ../data/vctk/speaker1/vctk-speaker1-val.4.16000.8192.4096.h5 \
  -e 120 \
  --batch-size 64 \
  --lr 3e-4 \
  --logname singlespeaker \
  --model audiotfilm \
  --r 4 \
  --layers 4 \
  --piano false \
  --pool_size 2 \
  --strides 2
  --full true

@Sawyerb
Copy link
Collaborator

Sawyerb commented Jun 29, 2021

And you can't train data files with dimension -1. (Those are just used to evaluate the "full" SNR on non-patched audio.)

If you're just looking to test out the code, I recommend sticking with the example code in the README.

@Sawyerb Sawyerb closed this as completed Nov 13, 2021
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

2 participants