C4W1A2-Dense function happyModel issues

If/when this is done, it isn’t done inside the Dense layer. Per the doc you linked, Dense returns

output = activation(dot(input, kernel) + bias)

Any threshold or clipping of that output has to be done as a post-processing step after the model completes forward propagation.

You are right. Not including a lecture note or instruction about this isn’t very nice. Sending students off to look at external documentation that also doesn’t include it is extra not nice. REQUEST for admins: please include a note in the lab notes saying that input_size = [list] IS an acceptable (and here, necessary) argument for tfl.ZeroPadding2D(). Thank you!

1 Like

in happyModel()
20 model = tf.keras.Sequential([
21 ## ZeroPadding2D with padding 3, input shape of 64 x 64 x 3
—> 22 tfl.ZeroPadding2D((3,3))(input_shape = (64, 64, 3)),
23 ## Conv2D with 32 7x7 filters and stride of 1
24 tfl.Conv2D(32, 7, stride = 1)(input_shape),

ValueError: The first argument to Layer.call must always be passed.

I got this error but I don’t understand what it’s means.

I appreciate if someone can help

Hello @Boubacar_Diallo,

The error happened in this line

 22 tfl.ZeroPadding2D((3,3))(input_shape = (64, 64, 3)),

Note that as stated in

image

Two parameters are needed to pass as arguments into ZeroPadding2D. From the way you code it, you have only passed one parameter, even though you have somehow put two things in that line. Here is how we should define a layer:

 tfl.ZeroPadding2D(argument_1_name = argument_1_value, argument_2_name = argument_2_value)

You have the right name for “input shape”, and you can look up the argument name for padding size from the layer’s documentation. Please check the other layers as well in the same way (both how many arguments are needed and their argument names) :slight_smile:

Cheers,
Raymond

Here is the way I code the ZeroPadding it now and the test passed, but I don’t unerstand well, what it works.

{code removed by mentor}

Hello @Boubacar_Diallo

It’s great to hear that you managed to fix it! The way you have done it is slightly different from the exercise’s description because you have added an “Input Layer” to specify the input_shape. You could have specify “input_shape” in the first layer of your Model, which is ZeroPadding2D, but either way will work because both of them lets your model know what the expected input shape is. Note that we only need to specify the input_shape once, and the model will figure out the other layers’ input shape automatically.

Cheers,
Raymond

PS: I have removed your solution code since we can’t share it here.