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

data_generator error prevents training #4

Open
GorillaBus opened this issue Nov 26, 2019 · 10 comments
Open

data_generator error prevents training #4

GorillaBus opened this issue Nov 26, 2019 · 10 comments

Comments

@GorillaBus
Copy link

There is an error in the data_generator function that, when trying to train the model, it will throw the following error:

could not broadcast input array from shape (168,2048) into shape (168)

The project was run from the cloned repo, dataset was copied and all paths are checked. All cell outputs until the training cell are equal to the original notebook.

@kp1181
Copy link

kp1181 commented May 8, 2020

@GorillaBus did you manage to get past the above error?

@kp1181
Copy link

kp1181 commented May 8, 2020

In def data_generator, while yielding use
yield [np.array(X1), np.array(X2)], np.array(y)

@GorillaBus
Copy link
Author

@kp1181 Hi, thanks for your reply. Let me check this tonight and I'll write back. Thanks!

@jha-vineet69
Copy link

@GorillaBus Did it work?

@KirolosAdeib
Copy link

Did anyone figure out the error reason?

@Abhishek1236
Copy link

yield ([array(X1), array(X2)], array(y)) this will work for sure .
Thanks

@poojapatil16
Copy link

Can anyone please help me to debug this error?
ValueError: in user code:
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:805 train_function *
return step_function(self, iterator)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:795 step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
/usr/local/lib/python3.7/dist-packages/tensorflow/python/distribute/distribute_lib.py:1259 run
return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/distribute/distribute_lib.py:2730 call_for_each_replica
return self._call_for_each_replica(fn, args, kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/distribute/distribute_lib.py:3417 _call_for_each_replica
return fn(*args, **kwargs)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:788 run_step **
outputs = model.train_step(data)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:754 train_step
y_pred = self(x, training=True)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/base_layer.py:998 call
input_spec.assert_input_compatibility(self.input_spec, inputs, self.name)
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/input_spec.py:207 assert_input_compatibility
' input tensors. Inputs received: ' + str(inputs))
ValueError: Layer model_1 expects 2 input(s), but it received 3 input tensors. Inputs received: [<tf.Tensor 'IteratorGetNext:0' shape=(None, None) dtype=float32>, <tf.Tensor 'IteratorGetNext:1' shape=(None, None) dtype=int32>, <tf.Tensor 'IteratorGetNext:2' shape=(None, None) dtype=float32>]

@jha-vineet69
Copy link

@poojapatil16 Did you try @kp1181's solution? It worked for me.

@Abhishek1236
Copy link

Abhishek1236 commented Apr 2, 2021 via email

@poojapatil16
Copy link

Thanks for your replies, issue is resolved.

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