Permalink
Browse files

Added support for noop when only caching.

  • Loading branch information...
1 parent 560935f commit f63f682a7771ceeced314f4466ed4eb2d1e3db8b @JohnLangford JohnLangford committed Sep 14, 2009
Showing with 65 additions and 32 deletions.
  1. +2 −2 Makefile
  2. +3 −3 README
  3. +19 −0 noop.cc
  4. +2 −0 noop.h
  5. +1 −12 parse_args.cc
  6. +30 −14 parse_regressor.cc
  7. +2 −1 parse_regressor.h
  8. +6 −0 vw.cc
View
@@ -15,7 +15,7 @@ FLAGS = -Wall $(ARCH) -ffast-math -fno-strict-aliasing -D_FILE_OFFSET_BITS=64 -I
#FLAGS = -Wall $(ARCH) -ffast-math -D_FILE_OFFSET_BITS=64 -I $(BOOST_INCLUDE) -pg -g
# for valgrind
-# FLAGS = -Wall $(ARCH) -ffast-math -D_FILE_OFFSET_BITS=64 -I $(BOOST_INCLUDE) -g -O0
+#FLAGS = -Wall $(ARCH) -ffast-math -D_FILE_OFFSET_BITS=64 -I $(BOOST_INCLUDE) -g -O0
BINARIES = vw offset_tree
@@ -43,7 +43,7 @@ gd.o: parse_example.h
%.o: %.cc
$(COMPILER) $(FLAGS) -c $< -o $@
-vw: hash.o io.o parse_regressor.o parse_primitives.o cache.o simple_label.o parse_example.o multisource.o sparse_dense.o parse_args.o gd.o parser.o vw.o loss_functions.o sender.o main.o
+vw: hash.o io.o parse_regressor.o parse_primitives.o cache.o simple_label.o parse_example.o multisource.o sparse_dense.o parse_args.o gd.o noop.o parser.o vw.o loss_functions.o sender.o main.o
$(COMPILER) $(FLAGS) -L$(BOOST_LIBRARY) -o $@ $+ $(LIBS)
offset_tree: hash.o io.o parse_regressor.o parse_primitives.o cache.o sparse_dense.o parse_example.o parse_args.o gd.o parser.o offset_tree.o loss_functions.o
View
6 README
@@ -8,13 +8,13 @@ release, and our intention is to create an open source project this
time.
Checked into github with clone URL:
-git://github.com/gparker/vowpal_wabbit.git
+git://github.com/JohnLangford/vowpal_wabbit.git
To get the code install git -- in a clean directory:
-git clone git://github.com/gparker/vowpal_wabbit.git
+git clone git://github.com/JohnLangford/vowpal_wabbit.git
-I've created a tag for the completely stock initial distribution '2.3'
+Gordon created a tag for the completely stock initial distribution '2.3'
so to check out that original release and create a branch based on it:
git checkout 2.3
View
19 noop.cc
@@ -0,0 +1,19 @@
+// This is a function which does nothing with examples. Used when VW is used as a compressor.
+
+#include "example.h"
+#include "parser.h"
+
+void start_noop()
+{
+ example* ec = NULL;
+
+ while ( (ec = get_example(ec,0)) )
+ {
+ ec->threads_to_finish = 1;
+ ec->done = true;
+ }
+}
+
+void end_noop()
+{
+}
View
2 noop.h
@@ -0,0 +1,2 @@
+void start_noop();
+void end_noop();
View
@@ -121,11 +121,8 @@ po::variables_map parse_args(int argc, char *argv[], boost::program_options::opt
}
}
- vector<string> regs;
- if (vm.count("initial_regressor"))
- regs = vm["initial_regressor"].as< vector<string> >();
+ parse_regressor_args(vm, r, final_regressor_name, !vars.quiet);
- parse_regressor(regs, r);
string loss_function;
if(vm.count("loss_function"))
loss_function = vm["loss_function"].as<string>();
@@ -187,14 +184,6 @@ po::variables_map parse_args(int argc, char *argv[], boost::program_options::opt
parse_send_args(vm, sd->pairs, sd->thread_bits);
- if (vm.count("final_regressor")) {
- final_regressor_name = vm["final_regressor"].as<string>();
- if (!vars.quiet)
- cerr << "final_regressor = " << vm["final_regressor"].as<string>() << endl;
- }
- else
- final_regressor_name = "";
-
if (vm.count("comment"))
{
comment = vm["comment"].as<string>();
View
@@ -28,19 +28,30 @@ void initialize_regressor(regressor &r)
}
}
-/*
- Read in regressors. If multiple regressors are specified, do a weighted
- average. If none are specified, initialize according to global_seg &
- numbits.
-*/
-void parse_regressor(vector<string> regressors, regressor &r)
+void parse_regressor_args(po::variables_map& vm, regressor& r, string& final_regressor_name, bool quiet)
{
+ if (vm.count("final_regressor")) {
+ final_regressor_name = vm["final_regressor"].as<string>();
+ if (!quiet)
+ cerr << "final_regressor = " << vm["final_regressor"].as<string>() << endl;
+ }
+ else
+ final_regressor_name = "";
+ vector<string> regs;
+ if (vm.count("initial_regressor"))
+ regs = vm["initial_regressor"].as< vector<string> >();
+
+ /*
+ Read in regressors. If multiple regressors are specified, do a weighted
+ average. If none are specified, initialize according to global_seg &
+ numbits.
+ */
bool initialized = false;
- for (size_t i = 0; i < regressors.size(); i++)
+ for (size_t i = 0; i < regs.size(); i++)
{
- ifstream regressor(regressors[i].c_str());
+ ifstream regressor(regs[i].c_str());
size_t local_num_bits;
regressor.read((char *)&local_num_bits, sizeof(local_num_bits));
if (!initialized){
@@ -109,16 +120,21 @@ void parse_regressor(vector<string> regressors, regressor &r)
regressor.close();
}
if (!initialized)
- initialize_regressor(r);
-
-// r.loss = getLossFunction(loss_function);
+ if(final_regressor_name != string(""))
+ initialize_regressor(r);
+ else
+ r.weight_vectors = NULL;
}
void free_regressor(regressor &r)
{
- for (size_t i = 0; i < r.global->num_threads(); i++)
- free(r.weight_vectors[i]);
- free(r.weight_vectors);
+ if (r.weight_vectors != NULL)
+ {
+ for (size_t i = 0; i < r.global->num_threads(); i++)
+ if (r.weight_vectors[i] != NULL)
+ free(r.weight_vectors[i]);
+ free(r.weight_vectors);
+ }
}
void dump_regressor(ofstream &o, regressor &r)
View
@@ -22,8 +22,9 @@ struct regressor {
loss_function *loss;
};
+void parse_regressor_args(po::variables_map& vm, regressor& r, string& final_regressor_name, bool quiet);
+
void initialize_regressor(regressor &r);
-void parse_regressor(vector<string> regs, regressor &r);
void finalize_regressor(ofstream& o, regressor &r);
void dump_regressor(ofstream &o, regressor &r);
View
6 vw.cc
@@ -16,6 +16,7 @@ embodied in the content of this file are licensed under the BSD
#include "parse_example.h"
#include "parse_args.h"
#include "gd.h"
+#include "noop.h"
#include "vw.h"
#include "simple_label.h"
#include "sender.h"
@@ -58,6 +59,11 @@ gd_vars* vw(int argc, char *argv[])
setup_send();
destroy_send();
}
+ else if (final_regressor_name == string("") && !vm.count("initial_regressor"))
+ {
+ start_noop();
+ end_noop();
+ }
else
{
setup_gd(t);

0 comments on commit f63f682

Please sign in to comment.