Matrix multiplication of a dlarray object in a custom loss function

조회 수: 7 (최근 30일)
Hi,
I have written a deep learning training loop with a custom loss function. Within this loss function, the output of my basic feedforward network is a dlarray matrix ~50(C) x 2000(B). The 50 channels in this matrix are a condensed representation of my desired output, which is a larger ~1500(C) x 2000(B) matrix. The matrix product of the output of my feedforward network with another (known) matrix gets me to this desired matrix, and from this I would like to calculate the mse loss. Essentially I need to reverse the eigendecomposition and calculate loss for that larger matrix, followed by a call to dlgradient to train my network. From reading documentation it seems that mtimes is not fully supported with dlarray objects. Am I missing an obvious alternative way to do what I want? I can manually do the matrix multiplication using scalar multiplication within loops but this is hopelessly slow. I would have expected this to not be an unusual step within custom training loops... can anyone suggest a way to accomplish this?
Many thanks!

채택된 답변

Sebastian Rosier
Sebastian Rosier 2022년 10월 17일
If anyone encounters the same issue, it turns out the matrix multiplication can be done with dlarray support using the pagemtimes function.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by