Ok, we have an answer. The problem is that you modified the normalize() routine, which is not graded and was just given to you in the template code. It is used to produce new_train, which is one of the inputs to that test case and the actual training later in the notebook.
Here’s what the function looks like in a clean notebook:
def normalize(image):
"""
Transform an image into a tensor of shape (64 * 64 * 3, )
and normalize its components.
Arguments
image - Tensor.
Returns:
result -- Transformed tensor
"""
image = tf.cast(image, tf.float32) / 255.0
image = tf.reshape(image, [-1,])
return image
And here’s what it is in your notebook:
def normalize(image):
"""
Transform an image into a tensor of shape (64 * 64 * 3, )
and normalize its components.
Arguments
image - Tensor.
Returns:
result -- Transformed tensor
"""
image = tf.cast(image, tf.float32)
image = tf.reshape(image, [-1,])
return image
See the difference? The input is just cast to float32, without the actual “normalization”. So why did you do that?
That function is not graded and there are no tests directly for it, since you weren’t supposed to modify it. But the output is used by a number of later graded cells in the notebook and other test cases.
Ok, you have one other problem as well: your compute_total_loss function is not correct. Please see this thread with a checklist of potential issues. You’ve got one of the ones on the list.
If the question is why the transposes are required, please have a look at this thread.
You can disregard my last post - I put the 355.0 in the wrong place
Thanks again so much - the notebook now works, and I think I got some experience with coding which I don’t fully understand yet, but I am l learning. I do think I understand the concepts but making it work is a challenge!. I would like to see more explicit instructions at the beginning of each part of the notebook - sometimes the instructions suggest brackets or " " should be used, or a lowercase x or w be used instead of X instead of just a ‘)’ or a variable name be used instead of its values - (((,( ( in the one hot coding code was really cinfusing
Remarkably, the autograder is still giving me credit only for 80% - so I wonder if there is a problem with it.
Here is the autorader code
Grades
Close
Passed
•
Grade Received: 80%
Submissions
(Required)
September 4, 2023 6:43 PM EDT (Highest Grade)
[ValidateApp | INFO] Validating ‘/home/jovyan/work/submitted/courseraLearner/W3A1/Tensorflow_introduction.ipynb’ [ValidateApp | INFO] Executing notebook with kernel: python3 2023-09-04 22:44:37.696771: 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 2023-09-04 22:44:37.696813: 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. 2023-09-04 22:44:39.000932: 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 2023-09-04 22:44:39.000975: W tensorflow/stream_executor/cuda/cuda_driver.cc:312] failed call to cuInit: UNKNOWN ERROR (303) 2023-09-04 22:44:39.001002: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (ip-10-2-92-201.ec2.internal): /proc/driver/nvidia/version does not exist 2023-09-04 22:44:39.001243: 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. 2023-09-04 22:44:39.028636: I tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency: 2999990000 Hz 2023-09-04 22:44:39.030577: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55d868f763a0 initialized for platform Host (this does not guarantee that XLA will be used). Devices: 2023-09-04 22:44:39.030621: 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 Tests failed on 1 cell(s)! These tests could be hidden. Please check your submission.
Have you actually read through all the outputs in the notebook? You must be failing some tests. Are you sure you fixed the bug in compute_total_loss that I mentioned?
Yes - I have checked all the modules and I actually let the computer run the whole Notebook. I don’t see any errors
I am uploading the notebook
{moderator edit - solution code removed}
Your code in compute_total_loss passes the tests, but it is not general. In the line that transposes the labels, you have hard-coded the size to be 6 classes. What if the grader uses a test case with a different number of classes? Why is the reshape necessary there in any case? I did not do that, just a simple transpose, and it worked for me.
You can disregard the last notebook I think I found the problem - I did not assign Y_true to labels and x_pree to logits. I will correct and see if the grade changes
Well, I fixed the one bug I showed above in compute_total_loss and now I get 100% from the grader with your notebook.
I had some other things to do but I have been thinking more how I might modify the code in the compute total loss module since that appears to be the problem with the aurtograder. In the suggestions it says that only 1 line of code is needed to do this. I wonder if what the autograder expects is just 1 line of code and one solution, and marks down for this if it does not see that, even if other code might well work
No, it’s not a problem with the autograder: it does not care about the number of lines. It does not look at the text of your code: it only runs the code and checks the answers.
I already pointed you to the problem in my earlier response: you have hard-coded the number 6 in the statement that should simply be computing the transpose of the labels. That means the code is not general and the grader must use a test case with a different number of “samples”.