Week 2 Lab Score Issue

Like someone earlier, the grader tells me my UNQ_C2 is in error. But, the internal notebook test indicates that the returned result from the code is correct. None of this is novel for me, and I do not see any error in the code. I see no global variables in the function.

A possible explanation is that I initially used np.sum and vector operations in the function. I noticed a 15th decimal difference in the second test output. So, I went back and implemented the function exactly as indicated in your hints. The internal test says it’s ok. But, the grader still says the function is incorrect. A possible explanation is that I added a code cell earlier to test what I was writing for UNQ_C1 and then erased it. Maybe the grader isn’t using the correct cell for the UNQ_C2 function?

Anyway, I’d be happy to share my code or try something else. Let me know–I’d like to pass this assignment.

A difference in the 15th decimal place is not likely to trigger the grader to fail your code. It has an tolerance to cover implementation and round-off/truncation differences.

Adding cells to the notebook is certain to confuse the grader. Removing any added cells should fix that. Be sure you manually save your notebook.

Changing any of the text around the “UNQxxx” labels will confuse the grader.

Also, do not change the file name of your notebook.

Also keep in mind that the grader tests your code using a totally different set of data. Your code must work in any situation and with any set of parameters.

Please verify that none of those issues apply.

After that, if you are still having issues, you can download your ipynb file and send it to me attached to a private message.

Thanks Tmosh!

I didn’t change any text around the ‘UNQxxx’ labels. There should be no reason the code would not work for a different data set. I added a cell and then erased it–so presumably not the problem. And, the results are highly accurate.

I did save the notebook internally to your server, with a ‘save as’ that required me to give the notebook a name. I’m sure the name it has now is not the same as whatever it started with. But I’m puzzled how it thinks the first function is correct if it is using the wrong file. Anyway, is there any way I can correct this or will I need to start from scratch? Relatedly, what do you mean by ‘manually save’ if not ‘save as’? Download?

Regardless of what notebook you have open when you press the “Submit” button, the grader is always going to use the default notebook name for that assignment.

You can use the “File → Rename…” tool to restore the original name.

The name it’s looking for is" “C1_W2_Linear_Regression.ipynb”.

Best to only use “File → Save as…” if you’re trying to store a backup copy for reference later.

“Manually save” means to click the “Save” tool button. Sometimes the auto-save feature either doesn’t work, or works very slowly. I’ve seen notebook updates that get lost if you change a cell and then immediately press the Submit button.

It’s actually grading the original notebook file at whatever state is was in when you started editing the copy with the new name.

I understand now why the grader isn’t correctly evaluating my notebook.

I tried to rename the file to the original, but it will not let me because the original is there. I see no way to erase the original.

PS I could copy / paste my solutions from the ‘saved as’ file back into the original notebook. However, I’m concerned you have plagiarism software that will flag this copying and pasting.

Problem fixed: I went back to the original file, which was half done, typed in my vector calculations, which didn’t take much time, and the grader had no problems.

Thank you for all your advice and info–I’m sure never to repeat this problem again!

1 Like

ValueError Traceback (most recent call last)
8 A3 = identity_block(X, f=2, filters=[4, 4, 3],
9 initializer=lambda seed=0:constant(value=1),
—> 10 training=False)
11 print(‘\033[1mWith training=False\033[0m\n’)
12 A3np = A3.numpy()

in identity_block(X, f, filters, training, initializer)
43 ## Final step: Add shortcut value to main path, and pass it through a RELU activation (≈2 lines)
—> 44 X = Add()([X, X_shortcut])
45 X = Activation(‘relu’)(X)

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py in call(self, *args, **kwargs)
980 with ops.name_scope_v2(name_scope):
981 if not self.built:
→ 982 self._maybe_build(inputs)
984 with ops.enable_auto_cast_variables(self._compute_dtype_object):

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py in _maybe_build(self, inputs)
2641 # operations.
2642 with tf_utils.maybe_init_scope(self):
→ 2643 self.build(input_shapes) # pylint:disable=not-callable
2644 # We must set also ensure that the layer is marked as built, and the build
2645 # shape is stored since user defined build functions may not be calling

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/utils/tf_utils.py in wrapper(instance, input_shape)
321 if input_shape is not None:
322 input_shape = convert_shapes(input_shape, to_tuples=True)
→ 323 output_shape = fn(instance, input_shape)
324 # Return shapes from fn as TensorShapes.
325 if output_shape is not None:

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/layers/merge.py in build(self, input_shape)
110 else:
111 shape = input_shape[i][1:]
→ 112 output_shape = self._compute_elemwise_op_output_shape(output_shape, shape)
113 # If the inputs have different ranks, we have to reshape them
114 # to make them broadcastable.

/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/layers/merge.py in _compute_elemwise_op_output_shape(self, shape1, shape2)
83 raise ValueError(
84 'Operands could not be broadcast ’
—> 85 'together with shapes ’ + str(shape1) + ’ ’ + str(shape2))
86 output_shape.append(i)
87 return tuple(output_shape)

ValueError: Operands could not be broadcast together with shapes (3, 3, 3) (4, 4, 3)