Cannot use Model.compile()?

Hi everyone ,

I got a trouble with Model.compile().

Here is my code:

def create_model(my_learning_rate , feature_layer , my_metrics):
    """Create and compile a simple classification model."""
    model = tf.keras.models.Sequential()
    model.add(tf.keras.layers.Dense(units=1 , input_shape=(1,) ,
    return model

Here is the log:

File “C:\Users\dell\OneDrive - khang06\My-Workspace\venv\lib\site-packages\keras\optimizers\optimizer_v2\”, line 140, in __init__super().init(name, kwargs)

File “C:\Users\dell\OneDrive - khang06\My-Workspace\venv\lib\site-packages\keras\optimizers\optimizer_v2\”, line 370, in __init__raise TypeError(TypeError: Unexpected keyword argument passed to optimizer: learning_rater. Allowed kwargs are {‘lr’, ‘global_clipnorm’, ‘clipnorm’, ‘clipvalue’, ‘decay’}.

Hopefully , i will be helped. Thanks.

There is a typo in the keyword argument passed to the optimizer. Please change learning_rater to learning_rate.


Thank you.

oh my bad , i didn’t see that i got a mistake in spelling.
Thank u

It gets another problem.

File “C:\Users\dell\OneDrive - khang06\My-Workspace\venv\lib\site-packages\keras\utils\”, line 70, in error_handler
raise e.with_traceback(filtered_tb) from None

File “C:\Users\dell\OneDrive - khang06\My-Workspace\venv\lib\site-packages\keras\engine\”, line 3544, in _validate_compile
raise TypeError(
TypeError: Invalid keyword argument(s) in compile(): ({‘metric’},). Valid keyword arguments include “cloning”, “experimental_run_tf_function”, “distribute”, “target_tensors”, or “sample_weight_mode”.

Can u help me please. Thank a lot

Please change the argument to metrics (not metric) in model.compile. For more details refer here.

i am really grateful to u . i hope that i didn’t make u feel being annoyed!

Definitely not. Glad the issue is resolved for you. Happy Learning!

1 Like