regularization_penalty
- opennmt.utils.regularization_penalty(regularization_type, scale, weights)[source]
Computes the weights regularization penalty.
- Parameters
regularization_type – The regularization type:
l1
,l2
, orl1_l2
.scale – The regularization multiplier. If
regularization_type
isl1_l2
, this should be a list or tuple containing the L1 regularization scale and the L2 regularization scale.weights – The list of weights.
- Returns
The regularization penalty.
- Raises
ValueError – if
regularization_type
is invalid or isl1_l2
butscale
is not a sequence.