For loop in custom loss function of deep neural network

2 views (last 30 days)
Hi,
Can anyone tell me whether matlab allows for loop in the customized loss function of a deep neural network?
Does it support complex number calculation in the custom loss function as well?

Accepted Answer

Mahesh Taparia
Mahesh Taparia on 13 Dec 2019
Hi Jubeyer
You can define a custom loss function in MATLAB, for example you can refer to this link. You can use for loop inside this loss function. Using for loop in the loss function will slower the training process as this function will be called for each batch of each epoch.
  11 Comments
Mahesh Taparia
Mahesh Taparia on 13 Dec 2019
Take the transpose of V_Y as you already did in your code previously.
Jubeyer Rahman
Jubeyer Rahman on 13 Dec 2019
I think I should be more specific about the problem I am facing here:
Here, in this operation:
Apparent_Y=V_Y.*conj(B * V_Y);
Let's say V_Y is 500X20 and B is 500X500
From vectorized operation what I need is when B*V_Y will be executed: it has to be in a way that each individual column of V_Y has to be multiplied with the whole B matrix and the result will be another 500X20 matrix (each time a column of V_Y is multiplied with the whole B, a column of 500X1 will be created; these columns need to be in a concatenated form which will make the desired resultant matrix of 500X20 matrix). So, just transposing V_Y does not solve the problem neither the elementwise multiplication, and I am doubtful whether while taking derivative any repmat type command is allowed or not.

Sign in to comment.

More Answers (0)

Categories

Find more on Image Data Workflows in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!