How to understand learnable parameters of cwtlayer and the underlying autograd calculation

32 views (last 30 days)
I was learning continuous wavelet transform (cwt) and found that there was a cwtlayer in Deep Learning Toolbox. The documentation of cwtlayer states that the dims(input) is 'CBT' and dims(output) is 'SCBT'. After I have read the source codes of cwtlayer, the crucial part of cwt calculation which is adopted from dlcwt.m shows as follows:
64 % FFT-IFFT only support unlabeled dlarrays
65 x = stripdims(x);
66 x = real(x);
67 % For this dlarray the third dimension is time
68 [C,B,~] = size(x);
69 xdft = fft(x,fftlen,3);
70 Nf = size(indices,1)-1;
71 psif = array2cwtfilters(psif,indices); % psif: reduced-weight tensor [1,1,Nr]; indices: bookkeeping matrix [Nf+1,4]
72 psif = reshape(psif,Nf,1,1,[]);
73 xdft = reshape(xdft,1,C,B,fftlen);
74 cfs = ifft(psif.*xdft,[],4);
75 if isempty(NVargs.DataFormat)
76 cfs = dlarray(cfs,'SCBT');
77 end
Through the codes illustrated above, the cwt calculation is implemented by fft-ifft along time 'T' dimension. Furthermore, the learnable parameter is reduced-weight tensor psif which is obtained from cwtfilters2array function. The reduced-weight tensor psif is a 1-by-1-by-Nr 3d tensor wherein Nr is the number of weights.
As far as I know, when training a deep neural network through backpropagation algorithm, each layer in the neural network should calculate a Jacobian in order to utilize automatic differentiation technology (e.g., PyTorch's autograd).
Questions: Q1. what the meaning of reduced-weight tensor psif represents in cwt.
Q2. what is the underlying calculation method to obtain the jacobian of a 'SCBT' tensor with regard to a 1-by-1-by-Nr tensor.

Accepted Answer

Meet
Meet on 17 Jun 2025 at 8:25
Hi Chuguang,
  1. Assuming you want to know the meaning of reduced weight tensor "psif" with respect to "cwtLayer", the "cwtLayer" uses a compact representation of the Continuous Wavelet Transform filter bank, known as the reduced-weight tensor "psif". This tensor is a 1-by-1-by-Nr array, where "Nr" is the number of significant filter coefficients retained after applying a threshold to the full CWT filter bank. The reduction process is handled by the function "cwtfilters2array", which extracts the most impactful values from each filter, effectively compressing the filter bank for more efficient training and inference.
  2. The Jacobian matrix J is computed automatically by MATLAB's autograd system "dlgradient". MATLAB's Deep Learning Toolbox internally tracks the FFT-IFFT operations and frequency-domain multiplication as differentiable functions.
For more information, please refer to the below MathWorks documentation links:
Hope this helps!

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!