Hi dear community, I have a question while finishing my week 3 assignment, so the feedback after submission says Cell #UNQ_C5. Can’t compile the student’s code. Error: NameError(“name ‘l2’ is not defined”)
and can you help me with adjust my code, do not really know how to fix this from my side:
UNQ_C5
GRADED CELL: model_r
tf.random.set_seed(1234)
model_r = Sequential([
Dense(120, activation=‘relu’, kernel_regularizer=l2(0.1)), # First dense layer with L2 regularization
Dense(40, activation=‘relu’, kernel_regularizer=l2(0.1)), # Second dense layer with L2 regularization
Dense(6, activation=‘linear’) # Output dense layer without activation modification
], name=“Complex_Regularized”)
Firstly, make sure that you have imported the necessary libraries at the beginning of your notebook. You need to import the l2 function from the tensorflow.keras.regularizers module. You can do this by running the cell that contains:
from tensorflow.keras.regularizers import l2
Make sure you have modified the code only in the allowed places and have not deleted any essential code. If the issue persists, consider resetting your notebook to the last checkpoint and rewriting your code from the beginning.
Hi @Alireza_Saei@TMosh,
Thanks for the guidance!! YEESSS I modified the code, and now I passed!!!
Also this is my final assignment to pass, and now I got my ML specialization certification