def regularize_layer_params_weighted(layers, penalty, tags={'regularizable': True}, **kwargs):
 return sum(((coeff * apply_penalty(layer.get_params(**tags), penalty, **kwargs)) for (layer, coeff) in layers.items()))

def regularize_layer_params_weighted ( layers , penalty , tags = { 'regularizable' : True } , ** kwargs ) : return sum ( ( ( coeff * apply_penalty ( layer . get_params ( ** tags ) , penalty , ** kwargs ) ) for ( layer , coeff ) in layers . items ( ) ) )
computes a regularization cost by applying a penalty to the parameters of a layer or group of layers .