本文整理汇总了C++中Benchmark::load方法的典型用法代码示例。如果您正苦于以下问题:C++ Benchmark::load方法的具体用法?C++ Benchmark::load怎么用?C++ Benchmark::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Benchmark
的用法示例。
在下文中一共展示了Benchmark::load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char *argv[])
{
string data_file;
string benchmark;
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "produce help message.")
("data,D", po::value<string>(&data_file), "data file")
("benchmark,B", po::value<string>(&benchmark), "benchmark file")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
FloatMatrix data(data_file);
Benchmark<> bench;
bench.load(benchmark);
for (unsigned i = 0; i < bench.getQ(); ++i) {
const float *p = data[bench.getQuery(i)];
cout << p[0];
for (int d = 1; d < data.getDim(); ++d) {
cout << ' ' << p[d];
}
cout << endl;
}
return 0;
}
示例2: main
int main (int argc, char *argv[])
{
string data_file;
string benchmark;
string index_file;
float W, R, desired_recall = 1.0;
unsigned M, L, H;
unsigned Q, K, T;
bool do_recall = false;
bool do_benchmark = true;
bool use_index = false; // load the index from a file
boost::timer timer;
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "produce help message.")
(",W", po::value<float>(&W)->default_value(1.0), "")
(",M", po::value<unsigned>(&M)->default_value(1), "")
(",T", po::value<unsigned>(&T)->default_value(1), "# probes")
(",L", po::value<unsigned>(&L)->default_value(1), "# hash tables")
(",Q", po::value<unsigned>(&Q)->default_value(100), "# queries")
(",K", po::value<unsigned>(&K)->default_value(0), "# nearest neighbor to retrieve")
("radius,R", po::value<float>(&R)->default_value(numeric_limits<float>::max()), "R-NN distance range (L2)")
("recall", po::value<float>(&desired_recall), "desired recall")
("data,D", po::value<string>(&data_file), "data file")
("benchmark,B", po::value<string>(&benchmark), "benchmark file")
("index", po::value<string>(&index_file), "index file")
(",H", po::value<unsigned>(&H)->default_value(1017881), "hash table size, use the default value.")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help") || (vm.count("data") < 1))
{
cout << desc;
return 0;
}
if (vm.count("radius") >= 1) {
R *= R; // we use L2sqr in the program.
}
if (vm.count("recall") >= 1)
{
do_recall = true;
if (K == 0) {
cerr << "Automatic probing does not support R-NN query." << endl;
}
}
if ((Q == 0) || (vm.count("benchmark") == 0)) {
do_benchmark = false;
}
if (vm.count("index") == 1) {
use_index = true;
}
cout << "LOADING DATA..." << endl;
timer.restart();
FloatMatrix data(data_file);
cout << boost::format("LOAD TIME: %1%s.") % timer.elapsed() << endl;
typedef MultiProbeLshIndex<unsigned> Index;
FloatMatrix::Accessor accessor(data);
Index index;
// try loading index
bool index_loaded = false;
if (use_index) {
ifstream is(index_file.c_str(), ios_base::binary);
if (is) {
is.exceptions(ios_base::eofbit | ios_base::failbit | ios_base::badbit);
cout << "LOADING INDEX..." << endl;
timer.restart();
index.load(is);
BOOST_VERIFY(is);
cout << boost::format("LOAD TIME: %1%s.") % timer.elapsed() << endl;
index_loaded = true;
}
}
if (!index_loaded) {
// We define a short name for the MPLSH index.
Index::Parameter param;
// Setup the parameters. Note that L is not provided here.
param.W = W;
param.range = H; // See H in the program parameters. You can just use the default value.
param.repeat = M;
param.dim = data.getDim();
DefaultRng rng;
index.init(param, rng, L);
//.........这里部分代码省略.........
示例3: main
int main (int argc, char *argv[])
{
string data_file;
string benchmark;
float R, W;
unsigned c, L, H;
unsigned Q, K;
bool do_benchmark = true;
// bool use_index = false; // load the index from a file
boost::timer timer;
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "produce help message.")
(",c", po::value<unsigned>(&c)->default_value(20), "# points to scan from each tree")
(",L", po::value<unsigned>(&L)->default_value(1), "number of trees")
(",H", po::value<unsigned>(&H)->default_value(10), "maximal depth of tree")
(",W", po::value<float>(&W)->default_value(1.0), "hash function window size")
(",Q", po::value<unsigned>(&Q)->default_value(100), "number of queries to use")
(",K", po::value<unsigned>(&K)->default_value(50), "number of nearest neighbors to retrieve")
(",R", po::value<float>(&R)->default_value(numeric_limits<float>::max()), "R-NN distance range")
("data,D", po::value<string>(&data_file), "dataset path")
("benchmark,B", po::value<string>(&benchmark), "benchmark path")
// ("index", po::value<string>(&index_file), "index file")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help") || (vm.count("data") < 1))
{
cout << desc;
return 0;
}
if ((Q == 0) || (vm.count("benchmark") == 0)) {
do_benchmark = false;
}
/*
if (vm.count("index") == 1) {
use_index = true;
}
*/
cout << "LOADING DATA..." << endl;
timer.restart();
FloatMatrix data(data_file);
cout << boost::format("LOAD TIME: %1%s.") % timer.elapsed() << endl;
//typedef Tail<RepeatHash<CauchyLsh> > MyLsh;
typedef LSB<GaussianLsh> MyLsh;
typedef ForestIndex<MyLsh, unsigned> Index;
FloatMatrix::Accessor accessor(data);
metric::l2<float> l2(data.getDim());
Index index;
// bool index_loaded = false;
/*
if (use_index) {
ifstream is(index_file.c_str(), ios_base::binary);
if (is) {
is.exceptions(ios_base::eofbit | ios_base::failbit | ios_base::badbit);
cout << "LOADING INDEX..." << endl;
timer.restart();
index.load(is);
verify(is);
cout << boost::format("LOAD TIME: %1%s.") % timer.elapsed() << endl;
index_loaded = true;
}
}
if (!index_loaded) {
// We define a short name for the MPLSH index.
float min = numeric_limits<float>::max();
float max = -numeric_limits<float>::max();
for (unsigned i = 0; i < data.getSize(); ++i) {
for (unsigned j = 0; j < data.getDim(); ++j) {
if (data[i][j] > max) max = data[i][j];
if (data[i][j] < min) min = data[i][j];
}
}
*/
Index::Parameter param;
// Setup the parameters. Note that L is not provided here.
param.W = W;
param.dim = data.getDim();
DefaultRng rng;
index.init(param, rng, L, H);
//.........这里部分代码省略.........