Example in R2022b (error message has changed)
layers = [
imageInputLayer([28 28 1])
convolution2dLayer(5,16,'Padding','same')
batchNormalizationLayer
reluLayer('Name','relu_1')
convolution2dLayer(3,32,'Padding','same','Stride',2)
batchNormalizationLayer
reluLayer
convolution2dLayer(3,32,'Padding','same')
batchNormalizationLayer
reluLayer
additionLayer(2,'Name','add')
averagePooling2dLayer(2,'Stride',2)
fullyConnectedLayer(10)
softmaxLayer
classificationLayer];
lgraph = layerGraph(layers);
skipConv = convolution2dLayer(1,32,'Stride',2,'Name','skipConv');
lgraph = addLayers(lgraph,skipConv);
lgraph = connectLayers(lgraph,'relu_1','skipConv');
lgraph = connectLayers(lgraph,'skipConv','add/in2');
figure
plot(lgraph);
cnn=googlenet;
cnnLayers=layerGraph(cnn);
lg2=addLayers(cnnLayers,lgraph)
Error using nnet.cnn.LayerGraph/addLayers
lg2=addLayers(cnnLayers,lgraph)
↑
Invalid argument at position 2. Input must be an array of layers.