Course 4 Week 1 Assignment 2. Stuck on Hello Model function

Hi mentors and fellow students,

I am stuck at hello model function of the sequential APIs. Can anyone assist me with that. The error I am getting currently is:

TypeError: The added layer must be an instance of class Layer. Found: Tensor(“zero_padding2d_41/Pad:0”, shape=(None, 70, 70, 3), dtype=float32)

Thank you,
Kshitij Sharma

Hey, for the sequential model you don’t need to pass anything to the layer after initialising it. Here it seems that you have passed something to the dense layer. That seems to be the issue.

Hey @XpRienzo ,

I think there is some other problem as well. I tried passing nothing and got this error.

And passed the number of units as asked and got the following error.

Hey, you seem to have done the same for the ZeroPadding layer as you did to Dense it looks like. Could you check if you have used a () after you initialised the layer?

Side-note: Setting the activation and units to the Dense was fine because you were just initialising the layer and not passing any tensor through the layer.
So for the sequential model: you put layers as Layer(initialisation arguments), rather than Layer(initialisation arguments)(Tensor).

1 Like

Hey @XpRienzo,
I don’t understand tensorflow at all except for some of the lines of code in the course 2 assignment that made sense because they were just functions. I am not able to understand the tensor thing you mentioned above. I am unable to understand what I have done wrong in the ZeroPadding layer. I have been at this issue for a day now.
I am unable to understand this code. The documentation also isn’t helping much.

@kshitijsharma, I found this thread useful:
C4 Week1 happymodel

Also you’re going to need the ‘sigmoid’ activation in the Dense layer.

@kshitijsharma - For the zero padding layer, you only need to specify the arguments “padding=…” and “input_shape=…”

@TMosh Thank you so much. I got it this time. I really need to understand the concept of tensor and other related stuff. Can anyone suggest me something other than the documentation to understand the code well?

@kshitijsharma, I don’t have any specific recommendations. I use a lot of internet searches (including the Discourse forum), since the descriptions in the course materials are rather thin.