Course 4 Week 2 Assignment 2 Exercise 2 error

This is the error I keep getting in Exercise 2 of the 2nd assignment of week 2:


AssertionError Traceback (most recent call last)
in
10 [‘Dense’, (None, 1), 1281, ‘linear’]] #linear is the default activation
11
—> 12 comparator(summary(model2), alpaca_summary)
13
14 for layer in summary(model2):

~/work/W2A2/test_utils.py in comparator(learner, instructor)
14 def comparator(learner, instructor):
15 if len(learner) != len(instructor):
—> 16 raise AssertionError(f"The number of layers in the model is incorrect. Expected: {len(instructor)} Found: {len(learner)}")
17 for a, b in zip(learner, instructor):
18 if tuple(a) != tuple(b):

AssertionError: The number of layers in the model is incorrect. Expected: 8 Found: 7

I have no idea what I’m doing wrong. Am I missing an entire layer?

This is the code I’ve written for that block:

# UNQ_C2
# GRADED FUNCTION
def alpaca_model(image_shape=IMG_SIZE, 
# mentor edit: code removed

Please refrain from sharing your code publicly on the forum. This is against our Code of Conduct. If a mentor requires access to your code to assist you, they will reach out to you directly via a private message

image
Hint:
You need to provide a function argument here.

1 Like

Sorry about posting the code, and thank you for your reply! I tried adding x=data_augmentation(inputs), and it still gives the same error.

Side question, when data_augmentation (or rather data_augmenter, the function) was defined, it didn’t take any functional argument, so why would it need one here?

In the markup below, at “A” you put “inputs”.
This gives you ‘x’.
Then you use preprocess ‘x’ and get a new ‘x’.

image

This code in the function definition:
image

… gives you data_augmentation as a function pointer. You still have to give it some data to operate on.

1 Like

That fixed it. Thank you so much!

1 Like