%% Set and Get L2 Regularization Factor of dlnetwork Learnable Parameter
% Set and get the L2 regularization factor of a learnable parameter of a dlnetwork object.
% Create a dlnetwork object.

layers = [
    imageInputLayer([28 28 1],'Normalization','none','Name','in')
    convolution2dLayer(5,20,'Name','conv')
    batchNormalizationLayer('Name','bn')
    reluLayer('Name','relu')
    fullyConnectedLayer(10,'Name','fc')
    softmaxLayer('Name','sm')];

lgraph = layerGraph(layers);

dlnet = dlnetwork(lgraph);

% Set the L2 regularization factor of the 'Weights' learnable parameter of the convolution layer to 2 using the setL2Factor function.

factor = 2;
dlnet = setL2Factor(dlnet,'conv','Weights',factor);

% Get the updated L2 regularization factor using the getL2Factor function.

factor = getL2Factor(dlnet,'conv','Weights')

% Copyright 2020 The MathWorks, Inc.
%