Sum in function object
Show older comments
I am trying to write a function object for the next function:
but I can't seem to use the + operator when working with function objs.
Tried writing it like this:
loss = @(W, x, y) log(sum(W'*x)) - (y(10)*W(:,10)'*x + y(9)*W(:,9)'*x + y(8)*W(:,8)'*x + ...
y(7)*W(:,7)'*x + y(6)*W(:,6)'*x + y(5)*W(:,5)'*x+ y(4)*W(:,4)'*x + y(3)*W(:,3)'*x +y(2)*W(:,2)'*x + y(1)*W(:,1)'*x);
lossW = @(W) 0;
for i=1:n
lossW = @(W) lossW + loss(W, X(:, i), Y(i, :));
end
I need to minimize with respect to the W matrix and I can't find a way to do that.
Accepted Answer
More Answers (0)
Categories
Find more on Entering Commands in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!