how to fft2 with dlarray?

4 ビュー (過去 30 日間)
瑛杰
瑛杰 2025 年 1 月 5 日
コメント済み: 瑛杰 2025 年 1 月 6 日
use in neural network training which need to define loss function
the loss function calaulated by the network input and output like this:
loss = mse(I,Y);
Y is the input of the network and I is the parameter which need fft2 through the output of the network
if use the extractdata(), the result can't be used to calculate gradient by
dlgradient(loss, net.Learnables)
in this situation the gradient only equal 0

採用された回答

Matt J
Matt J 2025 年 1 月 5 日
編集済み: Matt J 2025 年 1 月 6 日
You haven't explained the difficulty you are experiencing, but I assume it is that an fft(), but not an fft2() command is available for dlarrays. However, you can build a 2D FFT out of 1D FFTs. Example:
X1=rand(400); %input to FFT
X2=dlarray(X1);
Y1=fft2(X1);
Y2=fft(fft(X2,[],2),[],1);
percentError = norm(Y1-extractdata(Y2),'inf')/norm(Y1,inf)*100
percentError = 1.3546e-13
  1 件のコメント
瑛杰
瑛杰 2025 年 1 月 6 日
Thank u for u reply!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

製品


リリース

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by