# I keep getting assertion error - Week 1 programming assignment 2

**URL:** <https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [June 3, 2021, 6:29pm UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562 "2021-06-03T18:29:00Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![venkat1](https://avatars.discourse-cdn.com/v4/letter/v/2acd7d/32.png) [@venkat1](https://community.deeplearning.ai/u/venkat1)\
**Post date:** [June 3, 2021, 6:29pm UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562/1 "2021-06-03T18:29:00Z")

</div>

Test failed  
Expected value

[‘ReLU’, (None, 64, 64, 8), 0]

does not match the input value:

[‘Activation’, (None, 64, 64, 8), 0]

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [June 3, 2021, 7:19pm UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562/2 "2021-06-03T19:19:50Z")

</div>

Which function are you working on? ReLU is used a lot of places in that assignment.

Are you using the Keras function for ReLU?

---

<div class="post-metadata">

**Author:** ![venkat1](https://avatars.discourse-cdn.com/v4/letter/v/2acd7d/32.png) [@venkat1](https://community.deeplearning.ai/u/venkat1)\
**Post date:** [June 3, 2021, 7:27pm UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562/3 "2021-06-03T19:27:43Z")

</div>

I use this:

## RELU

```
A1 = tf.keras.activations.relu(Z1)

```

---

<div class="post-metadata">

**Author:** ![venkat1](https://avatars.discourse-cdn.com/v4/letter/v/2acd7d/32.png) [@venkat1](https://community.deeplearning.ai/u/venkat1)\
**Post date:** [June 3, 2021, 7:33pm UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562/4 "2021-06-03T19:33:17Z")

</div>

I am working on this function convolutional\_model(input\_shape):

It seems to work after this assertion error though, when I do:  
history = conv\_model.fit(train\_dataset, epochs=100, validation\_data=test\_dataset) .

But due to the assertion error I am not graded I think. So kindly let me know what to do ?

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [June 3, 2021, 7:43pm UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562/5 "2021-06-03T19:43:40Z")

</div>

You are using the Keras “Functional API” here. So it’s a little more complicated than the way you have done it. It’s a two step process:

First you invoke the ReLU layer to create the function you want and then you invoke it. The first step looks like this:

`tfl.ReLU()`

Then to invoke that you do this:

`outputTensor = tfl.ReLU()(inputTensor)`

---

<div class="post-metadata">

**Author:** ![venkat1](https://avatars.discourse-cdn.com/v4/letter/v/2acd7d/32.png) [@venkat1](https://community.deeplearning.ai/u/venkat1)\
**Post date:** [June 3, 2021, 7:56pm UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562/6 "2021-06-03T19:56:04Z")

</div>

Its from week 1’s programming exercise 2 “convolution model application”.  
Yes, you are right, A1 = tf.keras.layers.ReLU()(Z1) did it. It works now.

I am still figuring out the sequential model. there was an assertion error but let me figure it out.

But thanks for the tip, it works now.

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [June 3, 2021, 7:59pm UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562/7 "2021-06-03T19:59:10Z")

</div>

In the Sequential API case, you are not actually invoking the function because the inputs are “implicit”. You just instantiate the function to specify the parameter settings (step 1 of my previous description).

---

<div class="post-metadata">

**Author:** ![venkat1](https://avatars.discourse-cdn.com/v4/letter/v/2acd7d/32.png) [@venkat1](https://community.deeplearning.ai/u/venkat1)\
**Post date:** [June 3, 2021, 8:00pm UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562/8 "2021-06-03T20:00:24Z")

</div>

Ok understood. Thanks

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [June 3, 2021, 8:01pm UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562/9 "2021-06-03T20:01:18Z")

</div>

[Here’s another recent threa](https://community.deeplearning.ai/t/course4-week-1-assignment-2-exercise-2/9742/4)d that describes the Functional API in a tiny bit more detail.

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [June 3, 2021, 8:21pm UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562/10 "2021-06-03T20:21:13Z")

</div>

> [@venkat1](#):
>
> `A1 = tf.keras.activations.relu(Z1)`

That’s the problem. You’re supposed to use the Keras functions for this exercise.

---

<div class="post-metadata">

**Author:** ![AyushMundra](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@AyushMundra](https://community.deeplearning.ai/u/AyushMundra)\
**Post date:** [July 2, 2021, 5:21pm UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562/11 "2021-07-02T17:21:25Z")

</div>

@venkat1 can you please help me. I have also the same query but I am not able to figure it out.

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [July 2, 2021, 10:16pm UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562/12 "2021-07-02T22:16:04Z")

</div>

Did you read my earlier responses on this thread and follow the links? I think all the information is there to figure it out if you have the exact same mistake the @venkat1 had.

---

<div class="post-metadata">

**Author:** ![AyushMundra](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@AyushMundra](https://community.deeplearning.ai/u/AyushMundra)\
**Post date:** [July 3, 2021, 8:58am UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562/13 "2021-07-03T08:58:50Z")

</div>

The problem is solved now. Thanks @paulinpaloalto

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [July 3, 2021, 2:33pm UTC](https://community.deeplearning.ai/t/i-keep-getting-assertion-error-week-1-programming-assignment-2/11562/14 "2021-07-03T14:33:56Z")

</div>

That’s great! Thanks for confirming.
