main Content

stftLayer

Short-time Fourier transform layer

Description

An STFT layer computes the short-time Fourier transform of the input.Use of this layer requires Deep Learning Toolbox™.

创建GydF4y2Ba

Description

例子GydF4y2Ba

layer=stftLayercreates aShort-Time Fourier Transform((STFT) layer. The input tostftLayermust be adlarray(深度学习工具箱)GydF4y2Ba对象中GydF4y2Ba"CBT"Format with a size along the time dimension greater than the length of窗户GydF4y2Ba。GydF4y2Ba

例子GydF4y2Ba

layer=stftLayer(名称=值GydF4y2Ba)GydF4y2Baspecifies optional parameters using name-value arguments. You can specify the analysis window and the format of the output, among others.

Properties

eXpand all

STFT

This property is read-only.

分析窗口用于计算STFT,该窗口指定为具有两个或两个元素的向量。GydF4y2Ba

Example:(1-COS(2*PI*(0:127)'/127))/2GydF4y2Baand汉恩GydF4y2Ba(128)GydF4y2Baboth specify a Hann window of length 128.

Data Types:double|GydF4y2Ba单身的GydF4y2Ba

This property is read-only.

number of overlapped samples, specified as a positive integer strictly smaller than the length of窗户GydF4y2Ba。GydF4y2Ba

The stride between consecutive windows is the difference between the window length and the number of overlapped samples.

Data Types:double|GydF4y2Ba单身的GydF4y2Ba

This property is read-only.

number of frequency points used to compute the discrete Fourier transform, specified as a positive integer greater than or equal to the window length. If not specified, this argument defaults to the length of the window.

If the length of the input data along the time dimension is less than the number of DFT points,stftLayerright-pads the data and the window with zeros so they have a length equal toFFTLength。GydF4y2Ba

Data Types:double|GydF4y2Ba单身的GydF4y2Ba

图层变换模式,指定为以下之一:GydF4y2Ba

  • “ mag”GydF4y2Ba- stft幅度GydF4y2Ba

  • “ Squaremag”GydF4y2Ba-STFT squared magnitude

  • “ logmag”GydF4y2Ba- stft幅度的自然对数GydF4y2Ba

  • “ logsquaremag”GydF4y2Ba- stft平方幅度的自然对数GydF4y2Ba

  • "realimag"-real and imaginary parts of the STFT, concatenated along the channel dimension

Data Types:char|GydF4y2Ba细绳GydF4y2Ba

layer output mode, specified as one of these:

  • "spatiotemporal"- 将输出格式为1-D图像的序列,其中图像高度对应于频率,第二维对应于通道,第三维对应于批处理,第四维对应于时间。GydF4y2Ba

    您可以使用此输出模式来馈送输出GydF4y2BastftLayerto a 1-D convolutional layer when you want to convolve along frequency. For more information, seeconvolution1dLayer(深度学习工具箱)GydF4y2Ba。GydF4y2Ba

  • "spatial"- 将输出格式化为2-D图像的序列,其中图像高度对应于频率,图像宽度对应于时间。第三和第四维分别对应于通道和批次。GydF4y2Ba

    您可以使用此输出模式来馈送输出GydF4y2BastftLayerto a 2-D convolutional layer when you want to convolve along the two spatial dimensions. For more information, seeconvolution2dLayer(深度学习工具箱)GydF4y2Ba。GydF4y2Ba

  • "temporal"- 将输出格式化为1-D序列。这种格式采用GydF4y2Ba"spatiotemporal"输出格式并将图像高度拉成通道尺寸。STFT输出的第二维对应于批处理,第三维对应于时间。GydF4y2Ba

    您可以使用此输出模式来馈送输出GydF4y2BastftLayer当您想随着时间的推移进行卷积时,到1D卷积层。有关更多信息,请参阅GydF4y2Baconvolution1dLayer(深度学习工具箱)GydF4y2Ba。You can also use this output mode to usestftLayer作为复发性神经网络的一部分。有关更多信息,请参阅GydF4y2BalstmLayer(深度学习工具箱)GydF4y2BaandGrulayerGydF4y2Ba(深度学习工具箱)GydF4y2Ba。GydF4y2Ba

Data Types:char|GydF4y2Ba细绳GydF4y2Ba

layer

multiplier for weight learning rate, specified as a nonnegative scalar. If not specified, this property defaults to zero, resulting in weights that do not update with training. You can also set this property using thesetLearnrateFactorGydF4y2Ba(深度学习工具箱)GydF4y2BaFunction.

Data Types:double|GydF4y2Ba单身的GydF4y2Ba

图层名称,,,,specified as a character vector or a string scalar. Forlayer数组输入,GydF4y2BatrainNetwork,,,,GydF4y2BaassembleNetwork,,,,GydF4y2BalayerGraph,,,,anddlnetworkFunctions automatically assign names to layers with name''。GydF4y2Ba

Data Types:char|GydF4y2Ba细绳GydF4y2Ba

This property is read-only.

number of inputs of the layer. This layer accepts a single input only.

Data Types:double

This property is read-only.

输入名称of the layer. This layer accepts a single input only.

Data Types:cell

This property is read-only.

输出数量of the layer. This layer has a single output only.

Data Types:double

This property is read-only.

Output names of the layer. This layer has a single output only.

Data Types:cell

Examples

collapse all

生成以600 Hz采样的信号2秒。该信号由正弦变化频率含量的呼叫组成。将信号存储在深度学习阵列中GydF4y2Ba“ CTB”GydF4y2Ba格式。GydF4y2Ba

Fs = 6e2; x = vco(sin(2*pi*(0:1/fs:2)),[0.1 0.4]*fs,fs); dlx = dlarray(x,“ CTB”GydF4y2Ba);

创建具有默认属性的短时傅立叶变换层。创建一个GydF4y2Badlnetwork由序列输入层和短时傅立叶变换层组成的对象。指定最小序列长度为128个样本。通过信号穿过GydF4y2Bapredictmethod of the network.

Ftl = stftLayer; dlnet = dlnetwork([sequenceInputLayer(1,MinLength=128) ftl]); netout = predict(dlnet,dlx);

Convert the network output to a numeric array. Use the挤GydF4y2BaFunction to remove the length-1 channel and batch dimensions. Plot the magnitude of the STFT. The first dimension of the array corresponds to frequency and the second to time.

q = extractdata(netout); waterfall(squeeze(q)') set(gca,XDir="reverse",,,,View=[30 45]) xlabel("Frequency")ylabel("Time")GydF4y2Ba

图包含一个轴对象。轴对象包含一个类型补丁的对象。GydF4y2Ba

Generate a 3 × 160 (× 1) array containing one batch of a three-channel, 160-sample sinusoidal signal. The normalized sinusoid frequencies areπ/4 rad/样品,GydF4y2Baπ/2 rad/样品,3GydF4y2Baπ/4 rad/sample. Save the signal as adlarray,,,,specifying the dimensions in order.dlarraypermutes the array dimensions to the"CBT"深度学习网络期望的形状。GydF4y2Ba

nch = 3; N = 160; x = dlarray(cos(pi.*(1:nch)'/4*(0:N-1)),“ CTB”GydF4y2Ba);

创建一个短时傅里叶变换层,can be used with the sinusoid. Specify a 64-sample rectangular window, 48 samples of overlap between adjoining windows, and 1024 DFT points. Specify the layer output mode as"spatial"。默认情况下,该层输出STFT的大小。GydF4y2Ba

stfl = stftLayer(Window=rectwin(64),...GydF4y2BaOverlapLength=48,...GydF4y2BaFFTLength=1024,...GydF4y2BaOutputMode=GydF4y2Ba"spatial");

创建一个两层GydF4y2Badlnetworkobject containing a sequence input layer and the STFT layer you just created. Treat each channel of the sinusoid as a feature. Specify the signal length as the minimum sequence length for the input layer.

layers = [sequenceInputlayer(NCH,minLength = n)stfl];dlnet = dlnetwork(层);GydF4y2Ba

正弦GydF4y2BaForwardmethod of the network.

dataout = forward(dlnet,x);

Convert the network output to a numeric array. Use the挤GydF4y2Ba功能折叠尺寸批次尺寸。瀑布图中的每个通道分别绘制STFT幅度。GydF4y2Ba

q = squeeze(extractdata(dataout));ForKJ = 1:NCH子图(NCH,1,KJ)瀑布(q(:,::,kj)')视图(30,45)Zlabel(GydF4y2Ba"Ch. "+string(kj))end

图包含3个轴对象。轴对象1包含一个类型补丁的对象。轴对象2包含一个类型补丁的对象。轴对象3包含一个类型补丁的对象。GydF4y2Ba

更多关于GydF4y2Ba

eXpand all

版本历史记录GydF4y2Ba

Introduced in R2021b

也可以看看GydF4y2Ba

应用GydF4y2Ba

对象GydF4y2Ba

  • (深度学习工具箱)GydF4y2Ba|GydF4y2Ba(深度学习工具箱)GydF4y2Ba

功能GydF4y2Ba

Topics