SpectralNormalization Layer (for SNGAN)
Version 1.1.0 (2.09 KB) by
KaSyow Riyuu
spectral normalization layer input : layer , name
recommend using spectralNormalize
layers = [
imageInputLayer(inputSize)
convolution2dLayer(filterSize,fs,'Stride',s,'Padding','same','Name','conv1')
] ;
lg = layerGraph(layers);
net = dlnetwork(lg);
u = nan;
v = nan;
% in each iteration before foward(net,x)
[u,v,net] = spectralNormalize(u,v,net)
--------------------------------------------------------------------------------------------------------------------------------
input a conv2d layer or transposedconv2d layer and name for sn layer.
inputlayer need : filter size , num filters (output channel size), num channels(input channel size).
example :
SpectralNormalization(convolution2dLayer(filterSize,numFilters,"NumChannels", 3, 'Stride',2,'Padding','same','Name','conv1') , "sn1" )
SpectralNormalization( transposedConv2dLayer(filterSize, numFilters,"NumChannels", 64, 'Name','detc5',"Stride",2 ,'Cropping','same') , "sn19" )
or you can see how the SpectralNormalization work in code, then coding by self
Cite As
KaSyow Riyuu (2026). SpectralNormalization Layer (for SNGAN) (https://au.mathworks.com/matlabcentral/fileexchange/91740-spectralnormalization-layer-for-sngan), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2021a
Compatible with R2021a
Platform Compatibility
Windows macOS LinuxTags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
