Info
此问题已关闭。 请重新打开它进行编辑或回答。
Loss_Fun how to programm it
1 次查看(过去 30 天)
显示 更早的评论
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));
0 个评论
回答(1 个)
Saumya Goel
2019-5-24
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 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!