# Programming Assignment: Transfer Learning with MobileNet

**URL:** <https://community.deeplearning.ai/t/programming-assignment-transfer-learning-with-mobilenet/3116>\
**Category:** Convolutional Neural Networks\
**Tags:** coursera-platform\
**Created:** [May 4, 2021, 5:17am UTC](https://community.deeplearning.ai/t/programming-assignment-transfer-learning-with-mobilenet/3116 "2021-05-04T05:17:17Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![DongdongSun](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@DongdongSun](https://community.deeplearning.ai/u/DongdongSun)\
**Post date:** [May 4, 2021, 5:17am UTC](https://community.deeplearning.ai/t/programming-assignment-transfer-learning-with-mobilenet/3116/1 "2021-05-04T05:17:17Z")

</div>

I have a submission problem that I have passed all the cases when I run in but only got a 33/100 on submission. I was able to run all the code on jupyter but the below message tells me that the function is not defined…

Please help

# Grader output [ValidateApp | INFO] Validating ‘/home/jovyan/work/submitted/courseraLearner/W2A2/Transfer\_learning\_with\_MobileNet\_v1.ipynb’ [ValidateApp | INFO] Executing notebook with kernel: python3 2021-05-04 05:13:18.295420: W tensorflow/stream\_executor/platform/default/dso\_loader.cc:59] Could not load dynamic library ‘libcudart.so.10.1’; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory 2021-05-04 05:13:18.295462: I tensorflow/stream\_executor/cuda/cudart\_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine. 2021-05-04 05:13:19.401103: W tensorflow/stream\_executor/platform/default/dso\_loader.cc:59] Could not load dynamic library ‘libcuda.so.1’; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory 2021-05-04 05:13:19.401136: W tensorflow/stream\_executor/cuda/cuda\_driver.cc:312] failed call to cuInit: UNKNOWN ERROR (303) 2021-05-04 05:13:19.401154: I tensorflow/stream\_executor/cuda/cuda\_diagnostics.cc:156] kernel driver does not appear to be running on this host (ip-10-3-0-50.ec2.internal): /proc/driver/nvidia/version does not exist 2021-05-04 05:13:19.401405: I tensorflow/core/platform/cpu\_feature\_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2 AVX512F FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2021-05-04 05:13:19.425698: I tensorflow/core/platform/profile\_utils/cpu\_utils.cc:104] CPU Frequency: 2999995000 Hz 2021-05-04 05:13:19.427776: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5591c2094a30 initialized for platform Host (this does not guarantee that XLA will be used). Devices: 2021-05-04 05:13:19.427804: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version Tests failed on 2 cell(s)! These tests could be hidden. Please check your submission.

The following cell failed:

```
from test_utils import summary, comparator

alpaca_summary = [['InputLayer', [(None, 160, 160, 3)], 0],
                    ['Sequential', (None, 160, 160, 3), 0],
                    ['TensorFlowOpLayer', [(None, 160, 160, 3)], 0],
                    ['TensorFlowOpLayer', [(None, 160, 160, 3)], 0],
                    ['Functional', (None, 5, 5, 1280), 2257984],
                    ['GlobalAveragePooling2D', (None, 1280), 0],
                    ['Dropout', (None, 1280), 0, 0.2],
                    ['Dense', (None, 1), 1281, 'linear']] #linear is the default ac...

comparator(summary(model2), alpaca_summary)

for layer in summary(model2):
    print(layer)

```

The error was:

```
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-17-adf7881e6456> in <module>
     10 ['Dense', (None, 1), 1281, 'linear']] #linear is the de...
     11 
---> 12 comparator(summary(model2), alpaca_summary)
     13 
     14 for layer in summary(model2):

NameError: name 'model2' is not defined

```

==========================================================================================  
The following cell failed:

```
assert type(loss_function) == tf.python.keras.losses.BinaryCrossentropy, "Not the c...
assert loss_function.from_logits, "Use from_logits=True"
assert type(optimizer) == tf.keras.optimizers.Adam, "This is not an Adam optimizer"
assert optimizer.lr == base_learning_rate / 10, "Wrong learning rate"
assert metrics[0] == 'accuracy', "Wrong metric"

print('\033[92mAll tests passed!')

```

The error was:

```
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-23-2a3573945f89> in <module>
----> 1 assert type(loss_function) == tf.python.keras.losses.BinaryCrossentropy, "N...
      2 assert loss_function.from_logits, "Use from_logits=True"
      3 assert type(optimizer) == tf.keras.optimizers.Adam, "This is not an Adam op...
      4 assert optimizer.lr == base_learning_rate / 10, "Wrong learning rate"
      5 assert metrics[0] == 'accuracy', "Wrong metric"

NameError: name 'loss_function' is not defined

```

---

<div class="post-metadata">

**Author:** ![pabloburchesgarcia](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pabloburchesgarcia](https://community.deeplearning.ai/u/pabloburchesgarcia)\
**Post date:** [May 4, 2021, 1:23pm UTC](https://community.deeplearning.ai/t/programming-assignment-transfer-learning-with-mobilenet/3116/3 "2021-05-04T13:23:44Z")

</div>

Me too!! What can we do?

---

<div class="post-metadata">

**Author:** ![fabhertz](https://avatars.discourse-cdn.com/v4/letter/f/848f3c/32.png) [@fabhertz](https://community.deeplearning.ai/u/fabhertz)\
**Post date:** [May 4, 2021, 1:37pm UTC](https://community.deeplearning.ai/t/programming-assignment-transfer-learning-with-mobilenet/3116/4 "2021-05-04T13:37:53Z")

</div>

I have exactly the same issue and I still haven’t found a solution.

---

<div class="post-metadata">

**Author:** ![Suhas](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@Suhas](https://community.deeplearning.ai/u/Suhas)\
**Post date:** [May 4, 2021, 1:45pm UTC](https://community.deeplearning.ai/t/programming-assignment-transfer-learning-with-mobilenet/3116/5 "2021-05-04T13:45:43Z")

</div>

Please keep us posted if you were able to resolve the issue.

---

<div class="post-metadata">

**Author:** ![DongdongSun](https://avatars.discourse-cdn.com/v4/letter/d/f08c70/32.png) [@DongdongSun](https://community.deeplearning.ai/u/DongdongSun)\
**Post date:** [May 4, 2021, 5:10pm UTC](https://community.deeplearning.ai/t/programming-assignment-transfer-learning-with-mobilenet/3116/6 "2021-05-04T17:10:17Z")

</div>

I have spent quite some time on this but still no progress. I think this really might be an error from the auto-grader.

---

<div class="post-metadata">

**Author:** ![laivict2](https://avatars.discourse-cdn.com/v4/letter/l/bbe5ce/32.png) [@laivict2](https://community.deeplearning.ai/u/laivict2)\
**Post date:** [May 4, 2021, 8:58pm UTC](https://community.deeplearning.ai/t/programming-assignment-transfer-learning-with-mobilenet/3116/7 "2021-05-04T20:58:24Z")

</div>

I also have this issue

---

<div class="post-metadata">

**Author:** ![Ouwayss](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/ouwayss/32/161404_2.png) [@Ouwayss](https://community.deeplearning.ai/u/Ouwayss)\
**Post date:** [May 4, 2021, 11:15pm UTC](https://community.deeplearning.ai/t/programming-assignment-transfer-learning-with-mobilenet/3116/8 "2021-05-04T23:15:49Z")

</div>

I have exactly the same problem

---

<div class="post-metadata">

**Author:** ![Camerata314](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@Camerata314](https://community.deeplearning.ai/u/Camerata314)\
**Post date:** [May 7, 2021, 6:05am UTC](https://community.deeplearning.ai/t/programming-assignment-transfer-learning-with-mobilenet/3116/9 "2021-05-07T06:05:10Z")

</div>

I have a slightly different issue… My grader says:

[ValidateApp | INFO] Executing notebook with kernel: python3  
2021-05-07 05:47:15.809103: W tensorflow/stream\_executor/platform/default/dso\_loader.cc:59] Could not load dynamic library ‘libcudart.so.10.1’; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory  
2021-05-07 05:47:15.809141: I tensorflow/stream\_executor/cuda/cudart\_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.  
2021-05-07 05:47:16.924893: W tensorflow/stream\_executor/platform/default/dso\_loader.cc:59] Could not load dynamic library ‘libcuda.so.1’; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory  
2021-05-07 05:47:16.924930: W tensorflow/stream\_executor/cuda/cuda\_driver.cc:312] failed call to cuInit: UNKNOWN ERROR (303)  
2021-05-07 05:47:16.924956: I tensorflow/stream\_executor/cuda/cuda\_diagnostics.cc:156] kernel driver does not appear to be running on this host (ip-10-3-0-61.ec2.internal): /proc/driver/nvidia/version does not exist  
2021-05-07 05:47:16.925190: I tensorflow/core/platform/cpu\_feature\_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2 AVX512F FMA  
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.  
2021-05-07 05:47:16.949434: I tensorflow/core/platform/profile\_utils/cpu\_utils.cc:104] CPU Frequency: 2999995000 Hz  
2021-05-07 05:47:16.951111: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55cd201e0750 initialized for platform Host (this does not guarantee that XLA will be used). Devices:  
2021-05-07 05:47:16.951137: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version  
[ValidateApp | ERROR] Timeout waiting for execute reply (30s).  
[ValidateApp | ERROR] Interrupting kernel  
Success! Your notebook passes all the tests.

---

<div class="post-metadata">

**Author:** ![laivict2](https://avatars.discourse-cdn.com/v4/letter/l/bbe5ce/32.png) [@laivict2](https://community.deeplearning.ai/u/laivict2)\
**Post date:** [May 8, 2021, 2:16pm UTC](https://community.deeplearning.ai/t/programming-assignment-transfer-learning-with-mobilenet/3116/10 "2021-05-08T14:16:46Z")

</div>

i opened jupyter notebook and submitted without running it and got 100/100, hopefully they fixed it!

---

<div class="post-metadata">

**Author:** ![mesontau1](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@mesontau1](https://community.deeplearning.ai/u/mesontau1)\
**Post date:** [May 10, 2021, 6:22am UTC](https://community.deeplearning.ai/t/programming-assignment-transfer-learning-with-mobilenet/3116/11 "2021-05-10T06:22:13Z")

</div>

This works for me too!

Just to add: at the first assignment of week 2 (ResNets) I also needed to comment everything practically after the last graded function (all code chunks from the one starting with: model.compile(optimizer=‘adam’, loss=‘categorical\_crossentropy’, metrics=[‘accuracy’]) ).
