Loss_Fun how to programm it
Información
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Mostrar comentarios más antiguos
Dear Community,
I have an optimazation problem.
I want to minimize the function:
L = Exp(0.5*pi)+ Exp(0.25*x)
I have the following code and need to understand it.
function [ LossVal, vol_pi, vol_x,vol_s ] = Loss_Fun( data, w_pi, w_x )
vol_pi = (mean(data.pi.^2));
vol_x = (mean(data.x.^2));
vol_s = (mean(data.st.^2));
LossVal = w_pi * vol_pi ...
+ w_x * vol_x ...
+ w_s * vol_s;
w_pi = 0.5 ; %1;
w_x = 0.25; %0.5;
end
As I understand w_pi and w_x are the weights of the paramater pi and x.
My problem is what is meant by data: Loss_Fun( data, w_pi, w_x )
vol_pi vol_x and vol_s should the mean, which I need for the function.
When Iam using this code for my model matlab gives me the errror:
Not enough input arguments.
Error in Loss_Fun (line 3)
vol_pi = (mean(data.pi.^2));
From where does matlab take this
vol_pi = (mean(data.pi.^2));
vol_x = (mean(data.x.^2));
vol_s = (mean(data.st.^2));
Respuestas (1)
Saumya Goel
el 24 de Mayo de 2019
0 votos
Whenever Loss_Fun is called, there are 3 input arguments that needs to be passed. So, data is one of them, which should contain -pi,x and st values on basis of which it will calculate the variables vol_pi,vol_x,vol_s.
Also, if you are looking for predefined functionalities on Optimization Problem, you may consider having a look at Optimization Toolbox: https://www.mathworks.com/help/optim/write-objective-function.html
1 comentario
Farah Shahpoor
el 24 de Mayo de 2019
La pregunta está cerrada.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!