tf.random.set_seed(1)
cost_fn = tf.keras.losses.MeanSquaredError()
opt = keras.optimizers.Adam(learning_rate=0.01)
model.compile(optimizer=opt,
loss=cost_fn)
where i cant writing this is error:
The error you are encountering indicates that the variable model has not been defined before you attempt to call model.compile(). To resolve this, you need to define your model before compiling it.
Cell #13. Can’t compile the student’s code. Error: NameError(“name ‘model’ is not defined”)
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.7/importlib/init.py”, line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1006, in _gcd_import
File “”, line 983, in _find_and_load
File “”, line 967, in _find_and_load_unlocked
File “”, line 677, in _load_unlocked
File “”, line 728, in exec_module
File “”, line 219, in _call_with_frames_removed
File “/tmp/student_solution_cells/cell_13.py”, line 18, in
model.compile(optimizer=opt,
NameError: name ‘model’ is not defined
And after i:
cost_fn = tf.keras.losses.MeanSquaredError() # Define your loss function
opt = tf.keras.optimizers.Adam(learning_rate=0.01) # Define your optimizer
The error message indicates that the variable model is not defined in the context where you’re trying to use it. It seems like user_NN and item_NN are used instead of the model. I suggest to use the default names provided by the notebook.
If you still need help with debugging please feel free to DM me your code.