Definition at line 19 of file PrecomputeKernelMatrix.h. References Impala::Core::Vector::Apply(), Chi2Distance(), Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::H(), ILOG_ERROR, ILOG_VAR, Impala::Core::Array::Pattern::PatMPixOp(), Impala::Core::Array::PixSum(), and Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::W(). Referenced by PrecomputeKernelMatrix(). 00022 { 00023 ILOG_VAR(Training.PrecomputeKernelMatrix); 00024 if(!(weights.size() == features.size())) 00025 { 00026 ILOG_ERROR("size of list does not match!"); 00027 return 0; 00028 } 00029 00030 std::vector<Matrix::Mat*> DistanceMatrices; 00031 std::vector<double> AList; 00032 // perhaps we should make this a pattern? 00033 std::vector<Feature::FeatureTable*>::iterator it; 00034 for(it=features.begin() ; it!=features.end() ; ++it) 00035 { 00036 Feature::FeatureTable* f = *it; 00037 00038 // fill a matrix with chi2 distance 00039 Matrix::Mat* m = Apply(&Training::Chi2Distance, f->GetColumn2(), f->GetColumn2()); 00040 DistanceMatrices.push_back(m); 00041 00042 // get A (average of all weights) 00043 double a = Array::PixSum(m); 00044 a /= m->W() * m->H(); 00045 AList.push_back(a); 00046 } 00047 00048 if(!(weights.size() == AList.size() == DistanceMatrices.size())) 00049 { 00050 ILOG_ERROR("size of list does not match!"); 00051 return 0; 00052 } 00053 // fill matrix with K(vi,vj) 00054 MpoChi2Kernel kernel(weights, AList); 00055 Array::Pattern::PatMPixOp(DistanceMatrices[0], DistanceMatrices, kernel); 00056 00057 for(int i=1 ; i<DistanceMatrices.size() ; ++i) 00058 delete DistanceMatrices[i]; 00059 return DistanceMatrices[0]; 00060 }
Here is the call graph for this function:
|