Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

void Impala::Core::Training::ApplyConceptsHelperKernels::LoadInfoFile (  )  [inline, private]

Definition at line 264 of file ApplyConceptsHelperKernels.h.

References Impala::Util::IOBuffer::Available(), Impala::Core::Database::RawDataSet::GetDatabase(), Impala::Util::StringParser::GetDouble(), Impala::Core::Database::RawDataSet::GetFilePathPrecomputedKernels(), Impala::Util::Database::GetIOBuffer(), Impala::Util::StringParser::GetString(), ILOG_ERROR, ILOG_INFO, mAnnoSet, mAverages, mFeatureDefs, mKernelMatrixName, mTotalWeight, mWeights, Impala::Util::IOBuffer::Read(), Impala::Util::IOBuffer::ReadLine(), and Impala::Util::IOBuffer::Valid().

Referenced by Initialise().

00265     {
00266         ILOG_INFO("loading featuredefs, weights and averages ");
00267         ILOG_DEBUG_NODE("annoset = " << (void*)mAnnoSet << " name = " <<
00268                         mKernelMatrixName);
00269         String path = mAnnoSet->GetFilePathPrecomputedKernels
00270             (mKernelMatrixName + ".input.txt", "", false, false);
00271         ILOG_DEBUG_NODE("reading input.txt");
00272         std::vector<String> lines;
00273         Util::IOBuffer* buf2 = mAnnoSet->GetDatabase()->GetIOBuffer
00274             (path, true, false, "");
00275         if(!buf2)
00276         {
00277             ILOG_ERROR("Could not read input.txt:" << path);
00278         }
00279         while(buf2->Available())
00280         {
00281             lines.push_back(buf2->ReadLine());
00282         }
00283         delete buf2;
00284         ILOG_DEBUG_NODE("read input.txt");
00285         if(lines.size() == 0)
00286             ILOG_ERROR(String("Could not load .input.txt file or file empty...\n")+
00287                        " Perhaps because the precomputed kernel is made with an"+
00288                        " old version? you can make this file by hand: each line"+
00289                        " has a weight and a featureDef just as the input to"+
00290                        " precomputekernelmatrix");
00291 
00292         mTotalWeight = 0;
00293         for(int i=0 ; i<lines.size() ; ++i)
00294         {
00295             ILOG_DEBUG_NODE("parsing line " << lines[i]);
00296             Util::StringParser p(lines[i]);
00297             Real64 weight = p.GetDouble();
00298             if(weight == 0)
00299                 ILOG_ERROR("parse error in .input.txt on line " << i <<
00300                            ": no weight found at beginning, or weight == 0");
00301             mTotalWeight += weight;
00302             mWeights.push_back(weight);
00303             String feature = p.GetString(' ', false);
00304             if(feature == "")
00305                 ILOG_ERROR("parse error in .input.txt on line " << i <<
00306                            ": no featureDef found");
00307             mFeatureDefs.push_back(Feature::FeatureDefinition(feature));
00308         }
00309 
00310         ILOG_DEBUG_NODE("done parsing " << mWeights.size() << " entries");
00312         String path2 = mAnnoSet->GetFilePathPrecomputedKernels
00313             (mKernelMatrixName + ".averages.raw", "", false, false);
00314         Util::IOBuffer* buf = mAnnoSet->GetDatabase()->GetIOBuffer
00315             (path2, true, false, "");
00316         if (buf && buf->Valid())
00317         {
00318             ILOG_DEBUG_NODE("loading averages");
00319             for(int i=0 ; i<mWeights.size() ; ++i)
00320             {
00321                 Real64 d;
00322                 buf->Read(&d, sizeof(Real64));
00323                 mAverages.push_back(d);
00324             }
00325         }
00326         delete buf;
00327 
00328         int size = mWeights.size();
00329         if((mAverages.size() != size) ||
00330            (mFeatureDefs.size() != size))
00331             ILOG_ERROR("trouble after loading: sizes do not match: weights="
00332                        << mWeights.size() << "; averages=" << mAverages.size() << 
00333                        "; featuredefs=" << mFeatureDefs.size());
00334     }

Here is the call graph for this function:


Generated on Fri Mar 19 11:23:15 2010 for ImpalaSrc by  doxygen 1.5.1