Convolutional Neural Networks Autograder issues

I am on week 2 assignment 2 and the autograder of this assignment is bugging out. I have been writing, clearing, deleting, and re-inserting cells in case of a hidden characters but nothing seems to fix it. When I run the cells, it works perfectly but the autograder keeps reporting the same error. No cell in the code is of line more than 29 lines but this error keeps appearing

Cell #UNQ_C2. Can’t compile the student’s code. Error: SyntaxError(“unmatched ‘)’”, (‘/tmp/student_solution_cells/cell_16.py’, 30, 5, ’ )'))
Traceback (most recent call last):
File “/home/www/app/grading/exceptions.py”, line 112, in handle_solution_errors
yield {}
File “/home/www/app/grading/abstract.py”, line 393, in _grade
context = compiled_code.run(cell_index=cell.index)
File “/home/www/app/grading/submission/compiled_code.py”, line 195, in run
return list(self._code_items.values())[cell_num - 1].run()
File “/home/www/app/grading/submission/compiled_code.py”, line 54, in run
return import_module(self.import_statement, items)
File “/usr/local/lib/python3.8/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1014, in _gcd_import
File “”, line 991, in _find_and_load
File “”, line 975, in _find_and_load_unlocked
File “”, line 671, in _load_unlocked
File “”, line 839, in exec_module
File “”, line 976, in get_code
File “”, line 906, in source_to_code
File “”, line 219, in _call_with_frames_removed
File “/tmp/student_solution_cells/cell_16.py”, line 30
)
^
SyntaxError: unmatched ‘)’

this mismatch appears in lines that are not even present and I have re-written codes of the graded assignment mutiple times to ensure it does not exist. Please help fix this issue

That’s usually how these sort of problems are caused, not how they are fixed.

I recommend you delete your notebook file and start over with a fresh copy - because fixing this sort of problem can take a very long time, and that takes away from your time for learning.

1 Like

That is the big mistake; you shouldn’t do all these. The only thing learners are supposed to do is to do their code between the ### START CODE HERE and ### END CODE HERE.

Anyway, please look for your alpaca_model again. Here is the template:


# UNQ_C2
# GRADED FUNCTION
def alpaca_model(image_shape=IMG_SIZE, data_augmentation=data_augmenter()):
    ''' Define a tf.keras model for binary classification out of the MobileNetV2 model
    Arguments:
        image_shape -- Image width and height
        data_augmentation -- data augmentation function
    Returns:
    Returns:
        tf.keras.model
    '''
    
    
    input_shape = image_shape + (3,)
    
    ### START CODE HERE
    
    base_model_path="imagenet_base_model/without_top_mobilenet_v2_weights_tf_dim_ordering_tf_kernels_1.0_160_no_top.h5"
    
    base_model = tf.keras.applications.MobileNetV2(input_shape=None,
                                                   include_top=None, # <== Important!!!!
                                                   weights=base_model_path)
    
    # freeze the base model by making it non trainable
    base_model.trainable = None 

    # create the input layer (Same as the imageNetv2 input size)
    inputs = tf.keras.Input(shape=None) 
    
    # apply data augmentation to the inputs
    x = None
    
    # data preprocessing using the same weights the model was trained on
    x = preprocess_input(None) 
    
    # set training to False to avoid keeping track of statistics in the batch norm layer
    x = base_model(None, training=None) 
    
    # add the new Binary classification layers
    # use global avg pooling to summarize the info in each channel
    x = None()(x) 
    # include dropout with probability of 0.2 to avoid overfitting
    x = None(None)(x)
        
    # use a prediction layer with one neuron (as a binary classifier only needs one)
    outputs = None
    
    ### END CODE HERE
    
    model = tf.keras.Model(inputs, outputs)
    
    return model
2 Likes

To get a new copy:

Go to the File → Open menu, select your notebook file, and click on the red trash-can icon.

Then go to “Lab Help” (the question-mark inside a circle), and use “Get Latest Version”.

Then you’ll need to exit the lab and re-enter it.

2 Likes

Or rename your existing notebook first to save your code for potentially “copy/pasting” later. But when you do that, be very careful (as Saif and Tom have said) only to modify the “YOUR CODE HERE” segments in the fresh clean copy.

But the key point to realize is that the “Get Latest Version” procedure will only replace missing files, which is the reason that you must first either delete or rename your notebook.

Also note that the grader will only grade the notebook with the standard name.

Here’s a thread which gives the full “tl;dr” details of this process.

2 Likes