Functions that impose constraints on weight values.
1 2 3 4 5 6 7 8
The maximum norm for the incoming weights.
The axis along which to calculate weight norms. For instance, in
a dense layer the weight matrix has shape
The minimum norm for the incoming weights.
The rate for enforcing the constraint: weights will be rescaled to yield (1 - rate) * norm + rate * norm.clip(low, high). Effectively, this means that rate=1.0 stands for strict enforcement of the constraint, while rate<1.0 means that weights will be rescaled at each step to slowly move towards a value inside the desired interval.
constraint_maxnorm() constrains the weights incident to each
hidden unit to have a norm less than or equal to a desired value.
constraint_nonneg() constraints the weights to be non-negative
constraint_unitnorm() constrains the weights incident to each hidden
unit to have unit norm.
constraint_minmaxnorm() constrains the weights incident to each
hidden unit to have the norm between a lower bound and an upper bound.
You can implement your own constraint functions in R. A custom
constraint is an R function that takes weights (
w) as input
and returns modified weights. Note that keras
k_greater_equal()) should be used in the
implementation of custom constraints. For example:
1 2 3 4 5 6
Note that models which use custom constraints cannot be serialized using
save_model_hdf5(). Rather, the weights of the model should be saved
and restored using
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.