Programming Assignment: Transfer Learning with MobileNet

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
4 Likes

Me too!! What can we do?

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

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

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

2 Likes

I also have this issue

1 Like

I have exactly the same problem

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.

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

1 Like

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’]) ).