Predicting Generalization in Deep Learning Forum

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

> Error during the ingestion program run


I am getting the following error during the ingestion program run, when submitting my code :

AttributeError: The layer has never been called and thus has no defined input shape.

This error generally occurs when proper input shape has not been provided at the first layer of a Sequential model. Can you please check and resolve this issue? I think expecting proper input shape to be provided at first layer so that we can access layer shapes downstream is a valid requirement.


Posted by: DepenM @ Oct. 7, 2020, 10:43 a.m.

Could you move the part of the code where you do inference to the front of the code where you compute the specifics of the weights?

Posted by: ydjiang @ Oct. 7, 2020, 5:30 p.m.

Seems like the issue persists.
We are looking into this.

Posted by: ydjiang @ Oct. 8, 2020, 12:39 a.m.

Does your solution work on the public data we provided?

Posted by: ydjiang @ Oct. 8, 2020, 1:29 a.m.

yes, the code works on the public data. That's because public data doesn't have any convolution layers. I have created a small custom dataset of my own, where the code works as well if the input shape is specified in the first layer of sequential model.

Posted by: DepenM @ Oct. 8, 2020, 4:23 a.m.

Oh I meant the public data that you have to downloaded separately (which contains CNN) not the sample data.
I guess it would run into the same problem on those data.

Posted by: ydjiang @ Oct. 8, 2020, 5:43 a.m.

No, I am not facing such an issue with the public data released. I guess it's because input shape is provided in all of those models.

Posted by: DepenM @ Oct. 8, 2020, 8:54 a.m.

Strange. Those models should be created in exactly the same way as the ones in private.

Posted by: ydjiang @ Oct. 8, 2020, 5 p.m.

I think I can bypass this error by performing a forward pass through the model layer by layer and recording the shape. However, yes its strange, that the code works on public data but fails on the private data.

Posted by: DepenM @ Oct. 8, 2020, 5:24 p.m.

I suspect I'm struggling with the same issue when extracting pre-activations, cfr.

Posted by: simonc @ Oct. 12, 2020, 9:05 a.m.

I think that input shape might be missing for some models in private data as I was able to replicate my issue on public data by removing input shape from model configs on public data. Maybe you can try to do the same and check if it replicates your issue.

Posted by: DepenM @ Oct. 12, 2020, 9:25 a.m.

Could you elaborate what the problem is?
The input_shape field in the .json file is actually not used to construct the keras model and all the config has this field.

Posted by: ydjiang @ Oct. 12, 2020, 4:36 p.m.

you can read "load_model" method in for how the input_shape is used.

Posted by: ydjiang @ Oct. 12, 2020, 4:43 p.m.

do you have tensorflow 2.2 locally?

Posted by: ydjiang @ Oct. 12, 2020, 4:50 p.m.

My local tf version is 2.3.0. I suspect maybe that is the reason my code works locally. Anyways, I was able to bypass the error and make the code work.

Posted by: DepenM @ Oct. 12, 2020, 5:19 p.m.

I confirm the problem comes from the tf version. I also had tf 2.3 locally... Thanks for the help!

Posted by: simonc @ Oct. 13, 2020, 10:16 a.m.
Post in this thread