def regularize_layer_params(layer, penalty, tags={'regularizable': True}, **kwargs):
 layers = ([layer] if isinstance(layer, Layer) else layer)
 all_params = []
 for layer in layers:
  all_params += layer.get_params(**tags)
 return apply_penalty(all_params, penalty, **kwargs)

def regularize_layer_params ( layer , penalty , tags = { 'regularizable' : True } , ** kwargs ) : layers = ( [ layer ] if isinstance ( layer , Layer ) else layer ) all_params = [ ] for layer in layers : all_params += layer . get_params ( ** tags ) return apply_penalty ( all_params , penalty , ** kwargs )
computes a regularization cost by applying a penalty to the parameters of a layer or group of layers .