# Transfer\_learning\_with\_MobileNet\_v1 Assignment 2 of week 2Exercise 3.3

**URL:** <https://community.deeplearning.ai/t/transfer-learning-with-mobilenet-v1-assignment-2-of-week-2exercise-3-3/22422>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [July 21, 2021, 12:05pm UTC](https://community.deeplearning.ai/t/transfer-learning-with-mobilenet-v1-assignment-2-of-week-2exercise-3-3/22422 "2021-07-21T12:05:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Akash02](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@Akash02](https://community.deeplearning.ai/u/Akash02)\
**Post date:** [July 21, 2021, 12:05pm UTC](https://community.deeplearning.ai/t/transfer-learning-with-mobilenet-v1-assignment-2-of-week-2exercise-3-3/22422/1 "2021-07-21T12:05:20Z")

</div>

I don’t know where its going wrong ..  
Any help is appreciated  
the error states:-  
----\> 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 optimizer.lr == base\_learning\_rate / 10, “Wrong learning rate”  
5 assert metrics[0] == ‘accuracy’, “Wrong metric”

AssertionError: Not the correct layer

this is my code:  
for layer in base\_model.layers[:fine\_tune\_at]:  
layer.trainable = False

# Define a BinaryCrossentropy loss function. Use from\_logits=True

loss\_function=True

# 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’

---

<div class="post-metadata">

**Author:** ![srikanthreddy21](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@srikanthreddy21](https://community.deeplearning.ai/u/srikanthreddy21)\
**Post date:** [July 22, 2021, 1:42am UTC](https://community.deeplearning.ai/t/transfer-learning-with-mobilenet-v1-assignment-2-of-week-2exercise-3-3/22422/2 "2021-07-22T01:42:29Z")

</div>

for defining BinaryCrossEntropyLoss we have to use function from tf.keras as below  
loss\_function=tf.keras.losses.BinaryCrossentropy(from\_logits=True)

Optimizer is correct in your code.

Accuracy should be in a list as below.  
metrics=[‘accuracy’]
