gistlib
main.mfunction layers = createResNetBlock(numFilters, kernelSize, stride, blockName) layers = [ convolution2dLayer(3, numFilters, 'Padding', 'same', 'Name', blockName + "_conv1") batchNormalizationLayer('Name', blockName + "_bn1") reluLayer('Name', blockName + "_relu1") convolution2dLayer(kernelSize, numFilters, 'Padding', 'same', 'Stride', stride, 'Name', blockName + "_conv2") batchNormalizationLayer('Name', blockName + "_bn2") ]; skipConnection = [ convolution2dLayer(1, numFilters, 'Stride', stride, 'Name', blockName + "_skipConv") batchNormalizationLayer('Name', blockName + "_skipBN") ]; layers = [ layers additionLayer(2, 'Name', blockName + "_add") reluLayer('Name', blockName + "_relu2") ]; layers = [ layers skipConnection ]; end 869 chars26 lines
function layers = createResNetBlock(numFilters, kernelSize, stride, blockName) layers = [ convolution2dLayer(3, numFilters, 'Padding', 'same', 'Name', blockName + "_conv1") batchNormalizationLayer('Name', blockName + "_bn1") reluLayer('Name', blockName + "_relu1") convolution2dLayer(kernelSize, numFilters, 'Padding', 'same', 'Stride', stride, 'Name', blockName + "_conv2") batchNormalizationLayer('Name', blockName + "_bn2") ]; skipConnection = [ convolution2dLayer(1, numFilters, 'Stride', stride, 'Name', blockName + "_skipConv") batchNormalizationLayer('Name', blockName + "_skipBN") ]; layers = [ layers additionLayer(2, 'Name', blockName + "_add") reluLayer('Name', blockName + "_relu2") ]; layers = [ layers skipConnection ]; end
This function creates a 1D ResNet block in MATLAB using convolutional layers, batch normalization, and skip connections.
gistlibby LogSnag