getL2Factor

Get L2 regularization factor of layer learnable parameter

Description

example

factor = getL2RateFactor(layer,parameterName) returns the L2 regularization factor of the parameter with the name parameterName in layer.

For built-in layers, you can get the L2 regularization factor directly by using the corresponding property. For example, for a convolution2dLayer layer, the syntax factor = getL2Factor(layer,'Weights',factor) is equivalent to factor = layer.WeightL2Factor.

Examples

collapse all

Set and get the L2 regularization factor of a learnable parameter of a layer.

Define a custom PReLU layer. To create this layer, save the file preluLayer.m in the current folder.

Create a layer array including a custom layer preluLayer.

layers = [ ...
    imageInputLayer([28 28 1])
    convolution2dLayer(5,20)
    batchNormalizationLayer
    preluLayer(20,'prelu')
    fullyConnectedLayer(10)
    softmaxLayer
    classificationLayer];

Set the L2 regularization factor of the 'Alpha' learnable parameter of the preluLayer to 2.

layers(4) = setL2Factor(layers(4),'Alpha',2);

View the updated L2 regularization factor.

factor = getL2Factor(layers(4),'Alpha')
factor = 2

Input Arguments

collapse all

Input layer, specified as a scalar Layer object.

Parameter name, specified as a character vector or a string scalar.

Introduced in R2017b