fundamentals of machine learning in kerasweight regularization is added by passing weight regularizer instances to layers as keyword arguments let' add weight regularization to the movie-review classification network listing adding weight regularizat ion he model from keras import regularizers model models sequential(model add(layers dense( kernel_regularizer=regularizers ( )activation='relu'input_shape=( ,))model add(layers dense( kernel_regularizer=regularizers ( )activation='relu')model add(layers dense( activation='sigmoid') ( means every coefficient in the weight matrix of the layer will add weight_coefficient_value to the total loss of the network note that because this penalty is only added at training timethe loss for this network will be much higher at training than at test time figure shows the impact of the regularization penalty as you can seethe model with regularization (dotshas become much more resistant to overfitting than the reference model (crosses)even though both models have the same number of parameters figure effect of weight regularizat ion on validation loss as an alternative to regularizationyou can use one of the following keras weight regularizers listing different weight regularizers available in keras from keras import regularizers regularizers ( regularization regularizers _l ( = = licensed to simultaneous and regularization