function [ bias ] = GetSoftBiasUno( weights, kernel, labels, C)
[xm xn] = size(kernel);
counter = 0;
bias = 0;
for i = 1:xm
if weights(i) > (10^-10) && weights(i) < (C - 10^(-10)) %calculate first <w xi>
sgnLastY = labels(i) > 0;
partialSum = 0;
for j = 1:xm
partialSum = partialSum + labels(j) * kernel(i,j) * weights(j);
end
%reset partial sum
wXi = partialSum;
partialSum = 0;
for j = i:xm
if weights(i) > (10^-10) && weights(i) < (C - 10^(-10)) && sgnLastY ~= (labels(j) > 0)
for j = 1:xm
partialSum = partialSum + labels(j) * kernel(i,j) * weights(j);
end
%save second <w xj>
wXj = partialSum;
bias = bias + -(wXi + wXj) / 2;
counter = counter + 1;
end
end
end
end
bias = bias / counter;
Friday Night Open Thread: Motivation
3 hours ago
No comments:
Post a Comment