Course 4 Week 3 Quizz: Question about lambda layer


I am wondering if there is an error on the question about what a lambda layer does. I selected “Changes the shape of the input or output data” and the question was graded as incorrect.

It does not change the shape but helps to fix the dimensions without rewriting our Window dataset helper function.
Check this link

My bad. I misunderstood the course. I looked up the documentation more in depth and understood that a Lambda layer can receive as input any custom function.

> import tensorflow as tf
> # Define your custom function that you want to apply element-wise
> def custom_function(x):
>     return x * 2 + 1
> # Create a Lambda layer that applies the custom function
> lambda_layer = tf.keras.layers.Lambda(custom_function)
> # Create a simple sequential model
> model = tf.keras.Sequential([
>     lambda_layer,
>     # Add more layers as needed
> ])
> # Compile and train the model
> # ...

I am leaving my post here in case useful to someone else

Thank you for the quick reply Deepti

Recently someone had a similar doubt, so it was faster solution for you to reply.

When we misunderstood concept, we learn and remember about those concepts more.

Keep Learning!!!


1 Like