ValueError( ValueError: Unrecognized keyword arguments passed to Dense: {'kernel_regulizer': <tensorflow.python.keras.regularizers.L2 object

Env- Windows 10
Pycharm 2021.3.3 (Community Edition)
Tensorflow 2.16.1
Keras 3.3.3
python 3.10

Issue1- from tensorflow.keras.layers import Dropout
Error encountered- Cannot find reference ‘keras’ in ‘init.py’

One solution that I found was to use this instead to solve this error
from tensorflow.python.keras.layers import Dropout

this solution did remove the above error but encountered a different error as below-

Issue2-
on using tf.keras.layers.Dense(32, activation=‘relu’, kernel_regulizer=regularizers.L2(0.01)),

raise ValueError(
ValueError: Unrecognized keyword arguments passed to Dense: {‘kernel_regulizer’: <tensorflow.python.keras.regularizers.L2 object at 0x00000262DB1AF52

How can this issue be solved?

Any updates on Issue1 can also help.

Hi @Jasmine_Kaur ,

Welcome to TensorFlow Forum ,

The error you’re encountering is due to a typo in the keyword argument. The correct argument name is kernel_regularizer.

 tf.keras.layers.Dense(32, activation='relu', kernel_regularizer=regularizers.L2(0.01))

Hope this resolve the issue ,

Thank You .