Course 4 week2 exercise3

AssertionError Traceback (most recent call last)
----> 1 assert type(loss_function) == tf.python.keras.losses.BinaryCrossentropy, “Not the correct layer”
2 assert loss_function.from_logits, “Use from_logits=True”
3 assert type(optimizer) == tf.keras.optimizers.Adam, “This is not an Adam optimizer”
4 assert == base_learning_rate / 10, “Wrong learning rate”
5 assert metrics[0] == ‘accuracy’, “Wrong metric”

AssertionError: Not the correct layer

I need help for my homework. I don’t konw how to solve this problem!

Hey man! I had issues in this part as well but I fixed them and I can show you where you might be getting the error!
Verify if these lines of code are similar to what you have typed in the code block where you have to type in the code:

Freeze all the layers before the fine_tune_at layer

for layer in base_model.layers[:fine_tune_at]:
layer.trainable = False

Define a BinaryCrossentropy loss function. Use from_logits=True

loss_function = tf.keras.losses.BinaryCrossentropy(from_logits = True, name = ‘binary_crossentropy’)

Define an Adam optimizer with a learning rate of 0.1 * base_learning_rate

optimizer = tf.keras.optimizers.Adam(learning_rate = 0.1 * base_learning_rate)

Use accuracy as evaluation metric

metrics = [‘accuracy’]

This should do the trick and your test cases should pass. Let me know if it works! Cheers!

Thanks! I have solve the problem.

1 Like