Predicting Generalization in Deep Learning Forum

Go back to competition Back to thread list Post in this thread

> Error while iterating through the data

I am trying iterate through the dataset but getting the following error:

ValueError: Input 0 of layer sequential is incompatible with the layer: its rank is undefined, but the layer requires a defined rank.

Even though code I am using to iterate through data is in one of the baselines and works fine in the shared colab notebook.

I am using
for i,(x,y) in enumerate(dataset.batch(128)):
output = model(x)

Please suggest a solution for this.

Posted by: Vashisht @ Aug. 10, 2020, 9:01 p.m.

Hi!

Are you sure you are iterating on the dataset outside of a tf.function ? Once you decorate a function with @tf.function, you can not iterate on the dataset inside it anymore. The recommended way of doing that is to let the function take a batch as input and iterate on the dataset outside the function.

Let me know if that solves it.

Posted by: pforet @ Aug. 10, 2020, 9:20 p.m.

Ok thanks for replying. I was actually iterating inside the function. I will make changes accordingly

Posted by: Vashisht @ Aug. 10, 2020, 9:35 p.m.
Post in this thread