As stated in the title, I would like to be able to penalize my model weights by creating a custom regularization term.
ex:
def customized_regularizer(weight_matrix, parameterA, parameterB):
return(K.sum(K.dot(parameterA, weight_matrix) - parameterB))
model.add(Dense(64, input_dim=64,
kernel_regularizer=customized_regularizer))
However, while looking at the Keras doc (https://keras.io/regularizers/), I see:
"Developing new regularizers Any function that takes in a weight matrix and returns a loss contribution tensor can be used as a regularizer, e.g..:"
Is it thus possible to create such a custom regularizer?