%% Replace Layer in Layer Graph
% Define a simple network architecture and plot it.

layers = [
    imageInputLayer([28 28 1],'Name','input')    
    convolution2dLayer(3,16,'Padding','same','Name','conv_1')
    reluLayer('Name','relu_1')    
    additionLayer(2,'Name','add')
    fullyConnectedLayer(10,'Name','fc')
    softmaxLayer('Name','softmax')
    classificationLayer('Name','classoutput')];

lgraph = layerGraph(layers);
lgraph = connectLayers(lgraph,'input','add/in2');

figure
plot(lgraph)

%
% Replace the ReLU layer in the network with a batch normalization layer followed by a leaky ReLU layer.

larray = [batchNormalizationLayer('Name','BN1')
          leakyReluLayer('Name','leakyRelu_1','Scale',0.1)];
lgraph = replaceLayer(lgraph,'relu_1',larray);

plot(lgraph)

% Copyright 2018 The MathWorks, Inc.