Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
58 lines (52 sloc)
1.78 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |