Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
function [thetaVals, instanceWeightsInEachBag] = getInstanceWeights(kernelWeights, allSeqsTransformationKernel)
% GETINSTANCEWEIGHTS
% Computes the theta values and instance weights from the sub-kernel weights and segment
% transformations
%
% INPUT PARAMS
% Param 'kernelWeights'
% Weights assigned by MKL tf each of the sub-kernels in the collection
%
% Param 'allSeqsTransformationKernel'
% Per sequence transformation of segments used to compute the instance weights
%
% OUTPUT PARAMS
% Param 'thetaVals'
% The theta values corresponding to each cluster centre
%
% Param 'instanceWeightsInEachBag'
% Weight for each segment per sequence
%
% ADDITIONAL NOTES
% -- Theta vals and sub-kernel weights follow a squared relation (Refer paper)
%
% -- Order followed is:
% . non-shifted kernels (1 to N) first, then shifted kernels (N+1 to 2N) in total 2N kernels
%
% -- Number of kernels is same as number of clusters
%
%
% Author: snikumbh@mpi-inf.mpg.de
thetaVals = sqrt(kernelWeights);
thetaVals = thetaVals';
nBags = size(allSeqsTransformationKernel,2);
nKernels = size(kernelWeights,1);
for j=1:nBags
instanceWeightsInEachBag{j} = zeros(size(allSeqsTransformationKernel{j},1) , 1);
end
% compute instance weights for instances in each bag
%
for j=1:nBags
temp = sum(repmat(thetaVals(1, 1 : nKernels ), ...
size(allSeqsTransformationKernel{j},1), 1) ...
.* allSeqsTransformationKernel{j}, 2);
instanceWeightsInEachBag{j} = temp;
% if to be written to file, pass fname to the function
% stdTemp = standardizeMatrix(temp');
% finalTemp = zeros(size(stdTemp));
% Using rankings
% [~, ranking] = sort(stdTemp(1:size(stdTemp,1),1:size(stdTemp,2)), 2, 'descend');
% finalTemp(1,ranking) = 1:size(stdTemp,2);
% dlmwrite(fname, finalTemp, '-append');
end
end