Hello,
I am having trouble on the Dense() portion of the model, or perhaps somewhere prior. With my limited knowledge the error message is not particularly helpful. I have read through the Dense() documentation and am failing to see my error. Any help appreciated. See error & code below.
Error:
“TypeError: The added layer must be an instance of class Layer. Found: tf.Tensor(…”
Hey! You don’t need to pass the input within the function itself. To pass the input shape, follow this part of Tensorflow’s official guide for Sequential Model.
The reason you’re getting this error is when you pass the input to the first layer (ZeroPadding2D) there, it turns into a tensor output rather than layer. And tf.keras.Sequential just expects layers there to build your model. Hopefully this helped you out.
Please do delete your code when you’ve solved your issue
Sorry, I don’t understand. If I am not to define the input within the function where can I? The function takes no input and I am hesitant to start changing code outside the given ‘#YOUR CODE STARTS HERE’ section.
As calling happy_model = happyModel() gives no input I get the error below.
“AttributeError: The layer has never been called and thus has no defined output shape.”
What am I missing? Thanks.
Hey, you should follow the guide I linked in the last post to solve that issue. you can define the input shape in the first layer without passing an input.
Okay I have got it, thanks for the help. Personally I found that section of the documentation confusing as it shows sending an input and calling model(x), whereas the solution is just to hardcode within the first layer.
I appreciate the rapid responses
Also, code is now deleted
Glad that you were able to figure it out. Good luck for the rest of the course!