fr.lip6.kernel.adaptative
Class ThreadedSumKernel<T>

java.lang.Object
  extended by fr.lip6.kernel.Kernel<T>
      extended by fr.lip6.kernel.adaptative.ThreadedSumKernel<T>
Type Parameters:
T -
All Implemented Interfaces:
java.io.Serializable

public class ThreadedSumKernel<T>
extends Kernel<T>

Major kernel computed as a weighted sum of minor kernels : K = w_i * k_i
Computation of the kernel matrix is done by running a thread on sub matrices. The number of threads is choosen as function of the number of available cpus.

Author:
dpicard
See Also:
Serialized Form

Field Summary
protected  int numThread
           
 
Fields inherited from class fr.lip6.kernel.Kernel
name
 
Constructor Summary
ThreadedSumKernel()
           
ThreadedSumKernel(java.util.Hashtable<Kernel<T>,java.lang.Double> h)
          Sets the weights to h.
 
Method Summary
 void addKernel(Kernel<T> k)
          adds a kernel to the sum with weight 1.0
 void addKernel(Kernel<T> k, double d)
          adds a kernel to the sum with weight d
 double[][] getKernelMatrix(java.util.ArrayList<TrainingSample<T>> e)
          return the Gram Matrix of this kernel computed on given samples
 double getWeight(Kernel<T> k)
          gets the weights of kernel k
 java.util.Hashtable<Kernel<T>,java.lang.Double> getWeights()
          get the list of kernels and associated weights.
 void removeKernel(Kernel<T> k)
          removes kernel k from the sum
 void setWeight(Kernel<T> k, java.lang.Double d)
          Sets the weight of kernel k
 double valueOf(T t1)
          kernel similarity to zero
 double valueOf(T t1, T t2)
          compute the kernel similarity between two element of input space
 
Methods inherited from class fr.lip6.kernel.Kernel
getNormalizedKernelMatrix, normalizedValueOf, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

numThread

protected int numThread
Constructor Detail

ThreadedSumKernel

public ThreadedSumKernel()

ThreadedSumKernel

public ThreadedSumKernel(java.util.Hashtable<Kernel<T>,java.lang.Double> h)
Sets the weights to h. Beware! It does not make a copy of h!

Parameters:
h -
Method Detail

addKernel

public void addKernel(Kernel<T> k)
adds a kernel to the sum with weight 1.0

Parameters:
k -

addKernel

public void addKernel(Kernel<T> k,
                      double d)
adds a kernel to the sum with weight d

Parameters:
k -
d -

removeKernel

public void removeKernel(Kernel<T> k)
removes kernel k from the sum

Parameters:
k -

getWeight

public double getWeight(Kernel<T> k)
gets the weights of kernel k

Parameters:
k -
Returns:
the weight associated with k

setWeight

public void setWeight(Kernel<T> k,
                      java.lang.Double d)
Sets the weight of kernel k

Parameters:
k -
d -

valueOf

public double valueOf(T t1,
                      T t2)
Description copied from class: Kernel
compute the kernel similarity between two element of input space

Specified by:
valueOf in class Kernel<T>
Parameters:
t1 - first element
t2 - second element
Returns:
the kernel value

valueOf

public double valueOf(T t1)
Description copied from class: Kernel
kernel similarity to zero

Specified by:
valueOf in class Kernel<T>
Parameters:
t1 - the element to compute the similarity to zero

getWeights

public java.util.Hashtable<Kernel<T>,java.lang.Double> getWeights()
get the list of kernels and associated weights.

Returns:
hashtable containing kernels as keys and weights as values.

getKernelMatrix

public double[][] getKernelMatrix(java.util.ArrayList<TrainingSample<T>> e)
Description copied from class: Kernel
return the Gram Matrix of this kernel computed on given samples

Overrides:
getKernelMatrix in class Kernel<T>
Returns:
double[][] containing similarities in the order of the e.