Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/vowpal_wabbit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Langford <jl@hunch.net>2015-01-01 00:22:55 +0300
committerJohn Langford <jl@hunch.net>2015-01-01 00:22:55 +0300
commitc316ebe62a2a428ab13841195bf7dc5420f5a1db (patch)
treecf1b1a3ebed90cbe7fd0874619f260507b908f7a
parent77aeb3194e8d5d2c5d7f3822c4f7b172a2d26ec2 (diff)
test now passing
-rw-r--r--Makefile2
-rw-r--r--library/gd_mf_weights.cc13
-rw-r--r--test/test-sets/ref/ml100k_small.stderr1
-rw-r--r--test/train-sets/ref/ml100k_small.stderr1
-rw-r--r--test/train-sets/ref/sequencespan_data.nonldf-bilou.test.stderr2
-rw-r--r--test/train-sets/ref/sequencespan_data.nonldf-bilou.train.stderr2
-rw-r--r--test/train-sets/ref/sequencespan_data.nonldf.train.stderr2
-rw-r--r--vowpalwabbit/cb_algs.cc4
-rw-r--r--vowpalwabbit/cbify.cc2
-rw-r--r--vowpalwabbit/gd_mf.cc161
-rw-r--r--vowpalwabbit/global_data.cc1
-rw-r--r--vowpalwabbit/global_data.h1
-rw-r--r--vowpalwabbit/kernel_svm.cc4
-rw-r--r--vowpalwabbit/nn.cc6
-rw-r--r--vowpalwabbit/parse_args.cc2
-rw-r--r--vowpalwabbit/parse_regressor.cc5
-rw-r--r--vowpalwabbit/parser.cc47
-rw-r--r--vowpalwabbit/search.cc5
18 files changed, 126 insertions, 135 deletions
diff --git a/Makefile b/Makefile
index 910adad0..0d53bb54 100644
--- a/Makefile
+++ b/Makefile
@@ -65,7 +65,7 @@ FLAGS = -std=c++0x $(CFLAGS) $(LDFLAGS) $(ARCH) $(WARN_FLAGS) $(OPTIM_FLAGS) -D_
#CXX = g++
# for valgrind / gdb debugging
-FLAGS = -std=c++0x $(CFLAGS) $(LDFLAGS) $(ARCH) $(WARN_FLAGS) -ffast-math -D_FILE_OFFSET_BITS=64 $(BOOST_INCLUDE) -g -O0 -fPIC
+#FLAGS = -std=c++0x $(CFLAGS) $(LDFLAGS) $(ARCH) $(WARN_FLAGS) -ffast-math -D_FILE_OFFSET_BITS=64 $(BOOST_INCLUDE) -g -O0 -fPIC
# for valgrind profiling: run 'valgrind --tool=callgrind PROGRAM' then 'callgrind_annotate --tree=both --inclusive=yes'
#FLAGS = $(CFLAGS) $(LDFLAGS) -Wall $(ARCH) -ffast-math -D_FILE_OFFSET_BITS=64 $(BOOST_INCLUDE) -g -O2 -fomit-frame-pointer -ffast-math -fno-strict-aliasing -fPIC
diff --git a/library/gd_mf_weights.cc b/library/gd_mf_weights.cc
index 4b394775..268739a4 100644
--- a/library/gd_mf_weights.cc
+++ b/library/gd_mf_weights.cc
@@ -52,12 +52,17 @@ int main(int argc, char *argv[])
vw* model = VW::initialize(vwparams);
model->audit = true;
+ string target("--rank ");
+ size_t loc = vwparams.find(target);
+ const char* location = vwparams.c_str()+loc+target.size();
+ size_t rank = atoi(location);
+
// global model params
unsigned char left_ns = model->pairs[0][0];
unsigned char right_ns = model->pairs[0][1];
weight* weights = model->reg.weight_vector;
size_t mask = model->reg.weight_mask;
-
+
// const char *filename = argv[0];
FILE* file = fopen(infile.c_str(), "r");
char* line = NULL;
@@ -86,7 +91,7 @@ int main(int argc, char *argv[])
left_linear << f->feature << '\t' << weights[f->weight_index & mask];
left_quadratic << f->feature;
- for (size_t k = 1; k <= model->rank; k++)
+ for (size_t k = 1; k <= rank; k++)
left_quadratic << '\t' << weights[(f->weight_index + k) & mask];
}
left_linear << endl;
@@ -101,8 +106,8 @@ int main(int argc, char *argv[])
right_linear << f->feature << '\t' << weights[f->weight_index & mask];
right_quadratic << f->feature;
- for (size_t k = 1; k <= model->rank; k++)
- right_quadratic << '\t' << weights[(f->weight_index + k + model->rank) & mask];
+ for (size_t k = 1; k <= rank; k++)
+ right_quadratic << '\t' << weights[(f->weight_index + k + rank) & mask];
}
right_linear << endl;
right_quadratic << endl;
diff --git a/test/test-sets/ref/ml100k_small.stderr b/test/test-sets/ref/ml100k_small.stderr
index c8bcbb51..92b91e64 100644
--- a/test/test-sets/ref/ml100k_small.stderr
+++ b/test/test-sets/ref/ml100k_small.stderr
@@ -3,7 +3,6 @@ Num weight bits = 16
learning rate = 10
initial_t = 1
power_t = 0.5
-rank = 10
using no cache
Reading datafile = test-sets/ml100k_small_test
num sources = 1
diff --git a/test/train-sets/ref/ml100k_small.stderr b/test/train-sets/ref/ml100k_small.stderr
index 3f3d6e25..462dca37 100644
--- a/test/train-sets/ref/ml100k_small.stderr
+++ b/test/train-sets/ref/ml100k_small.stderr
@@ -6,7 +6,6 @@ learning rate = 0.05
initial_t = 1
power_t = 0
decay_learning_rate = 0.97
-rank = 10
creating cache_file = train-sets/ml100k_small_train.cache
Reading datafile = train-sets/ml100k_small_train
num sources = 1
diff --git a/test/train-sets/ref/sequencespan_data.nonldf-bilou.test.stderr b/test/train-sets/ref/sequencespan_data.nonldf-bilou.test.stderr
index aad69ced..5b3afa22 100644
--- a/test/train-sets/ref/sequencespan_data.nonldf-bilou.test.stderr
+++ b/test/train-sets/ref/sequencespan_data.nonldf-bilou.test.stderr
@@ -1,10 +1,10 @@
only testing
+switching to BILOU encoding for sequence span labeling
Num weight bits = 18
learning rate = 10
initial_t = 1
power_t = 0.5
predictions = sequencespan_data.predict
-switching to BILOU encoding for sequence span labeling
using no cache
Reading datafile = train-sets/sequencespan_data
num sources = 1
diff --git a/test/train-sets/ref/sequencespan_data.nonldf-bilou.train.stderr b/test/train-sets/ref/sequencespan_data.nonldf-bilou.train.stderr
index f0c914e0..a4fc72a6 100644
--- a/test/train-sets/ref/sequencespan_data.nonldf-bilou.train.stderr
+++ b/test/train-sets/ref/sequencespan_data.nonldf-bilou.train.stderr
@@ -1,10 +1,10 @@
final_regressor = models/sequencespan_data.model
+switching to BILOU encoding for sequence span labeling
Num weight bits = 18
learning rate = 10
initial_t = 1
power_t = 0.5
decay_learning_rate = 1
-switching to BILOU encoding for sequence span labeling
creating cache_file = train-sets/sequencespan_data.cache
Reading datafile = train-sets/sequencespan_data
num sources = 1
diff --git a/test/train-sets/ref/sequencespan_data.nonldf.train.stderr b/test/train-sets/ref/sequencespan_data.nonldf.train.stderr
index a75bbfd5..2ea5e7e1 100644
--- a/test/train-sets/ref/sequencespan_data.nonldf.train.stderr
+++ b/test/train-sets/ref/sequencespan_data.nonldf.train.stderr
@@ -1,10 +1,10 @@
final_regressor = models/sequencespan_data.model
+no rollout!
Num weight bits = 18
learning rate = 10
initial_t = 1
power_t = 0.5
decay_learning_rate = 1
-no rollout!
creating cache_file = train-sets/sequencespan_data.cache
Reading datafile = train-sets/sequencespan_data
num sources = 1
diff --git a/vowpalwabbit/cb_algs.cc b/vowpalwabbit/cb_algs.cc
index 2d8a2252..c676f547 100644
--- a/vowpalwabbit/cb_algs.cc
+++ b/vowpalwabbit/cb_algs.cc
@@ -496,7 +496,7 @@ namespace CB_ALGS
*all.file_options << " --cb_type dr";
}
- if (!vm.count("csoaa"))
+ if (count(all.args.begin(), all.args.end(),"--csoaa") == 0)
{
all.args.push_back("--csoaa");
stringstream ss;
@@ -524,7 +524,7 @@ namespace CB_ALGS
}
// preserve the increment of the base learner since we are
// _adding_ to the number of problems rather than multiplying.
- l->increment = all.l->increment;
+ l->increment = base->increment;
l->set_init_driver(init_driver);
l->set_finish(finish);
diff --git a/vowpalwabbit/cbify.cc b/vowpalwabbit/cbify.cc
index 776501f7..07e8fba1 100644
--- a/vowpalwabbit/cbify.cc
+++ b/vowpalwabbit/cbify.cc
@@ -390,7 +390,7 @@ namespace CBIFY {
data.k = (uint32_t)vm["cbify"].as<size_t>();
*all.file_options << " --cbify " << data.k;
- if (!vm.count("cb"))
+ if (count(all.args.begin(), all.args.end(),"--cb") == 0)
{
all.args.push_back("--cb");
stringstream ss;
diff --git a/vowpalwabbit/gd_mf.cc b/vowpalwabbit/gd_mf.cc
index 1a9a6335..4e91aeba 100644
--- a/vowpalwabbit/gd_mf.cc
+++ b/vowpalwabbit/gd_mf.cc
@@ -26,10 +26,12 @@ using namespace LEARNER;
namespace GDMF {
struct gdmf {
vw* all;
+ uint32_t rank;
};
-void mf_print_offset_features(vw& all, example& ec, size_t offset)
+void mf_print_offset_features(gdmf& d, example& ec, size_t offset)
{
+ vw& all = *d.all;
weight* weights = all.reg.weight_vector;
size_t mask = all.reg.weight_mask;
for (unsigned char* i = ec.indices.begin; i != ec.indices.end; i++)
@@ -53,7 +55,7 @@ void mf_print_offset_features(vw& all, example& ec, size_t offset)
if (ec.atomics[(int)(*i)[0]].size() > 0 && ec.atomics[(int)(*i)[1]].size() > 0)
{
/* print out nsk^feature:hash:value:weight:nsk^feature^:hash:value:weight:prod_weights */
- for (size_t k = 1; k <= all.rank; k++)
+ for (size_t k = 1; k <= d.rank; k++)
{
for (audit_data* f = ec.audit_features[(int)(*i)[0]].begin; f!= ec.audit_features[(int)(*i)[0]].end; f++)
for (audit_data* f2 = ec.audit_features[(int)(*i)[1]].begin; f2!= ec.audit_features[(int)(*i)[1]].end; f2++)
@@ -62,11 +64,11 @@ void mf_print_offset_features(vw& all, example& ec, size_t offset)
<<"(" << ((f->weight_index + offset +k) & mask) << ")" << ':' << f->x;
cout << ':' << weights[(f->weight_index + offset + k) & mask];
- cout << ':' << f2->space << k << '^' << f2->feature << ':' << ((f2->weight_index+k+all.rank)&mask)
- <<"(" << ((f2->weight_index + offset +k+all.rank) & mask) << ")" << ':' << f2->x;
- cout << ':' << weights[(f2->weight_index + offset + k+all.rank) & mask];
+ cout << ':' << f2->space << k << '^' << f2->feature << ':' << ((f2->weight_index+k+d.rank)&mask)
+ <<"(" << ((f2->weight_index + offset +k+d.rank) & mask) << ")" << ':' << f2->x;
+ cout << ':' << weights[(f2->weight_index + offset + k+d.rank) & mask];
- cout << ':' << weights[(f->weight_index + offset + k) & mask] * weights[(f2->weight_index + offset + k + all.rank) & mask];
+ cout << ':' << weights[(f->weight_index + offset + k) & mask] * weights[(f2->weight_index + offset + k + d.rank) & mask];
}
}
}
@@ -77,17 +79,25 @@ void mf_print_offset_features(vw& all, example& ec, size_t offset)
cout << endl;
}
-void mf_print_audit_features(vw& all, example& ec, size_t offset)
+void mf_print_audit_features(gdmf& d, example& ec, size_t offset)
{
- print_result(all.stdout_fileno,ec.pred.scalar,-1,ec.tag);
- mf_print_offset_features(all, ec, offset);
+ print_result(d.all->stdout_fileno,ec.pred.scalar,-1,ec.tag);
+ mf_print_offset_features(d, ec, offset);
}
-float mf_predict(vw& all, example& ec)
+float mf_predict(gdmf& d, example& ec)
{
+ vw& all = *d.all;
label_data& ld = ec.l.simple;
float prediction = ld.initial;
+ for (vector<string>::iterator i = d.all->pairs.begin(); i != d.all->pairs.end();i++)
+ {
+ ec.num_features -= ec.atomics[(int)(*i)[0]].size() * ec.atomics[(int)(*i)[1]].size();
+ ec.num_features += ec.atomics[(int)(*i)[0]].size() * d.rank;
+ ec.num_features += ec.atomics[(int)(*i)[1]].size() * d.rank;
+ }
+
// clear stored predictions
ec.topic_predictions.erase();
@@ -107,18 +117,18 @@ float mf_predict(vw& all, example& ec)
{
if (ec.atomics[(int)(*i)[0]].size() > 0 && ec.atomics[(int)(*i)[1]].size() > 0)
{
- for (uint32_t k = 1; k <= all.rank; k++)
+ for (uint32_t k = 1; k <= d.rank; k++)
{
// x_l * l^k
- // l^k is from index+1 to index+all.rank
+ // l^k is from index+1 to index+d.rank
//float x_dot_l = sd_offset_add(weights, mask, ec.atomics[(int)(*i)[0]].begin, ec.atomics[(int)(*i)[0]].end, k);
float x_dot_l = 0.;
GD::foreach_feature<float, GD::vec_add>(all.reg.weight_vector, all.reg.weight_mask, ec.atomics[(int)(*i)[0]].begin, ec.atomics[(int)(*i)[0]].end, x_dot_l, k);
// x_r * r^k
- // r^k is from index+all.rank+1 to index+2*all.rank
- //float x_dot_r = sd_offset_add(weights, mask, ec.atomics[(int)(*i)[1]].begin, ec.atomics[(int)(*i)[1]].end, k+all.rank);
+ // r^k is from index+d.rank+1 to index+2*d.rank
+ //float x_dot_r = sd_offset_add(weights, mask, ec.atomics[(int)(*i)[1]].begin, ec.atomics[(int)(*i)[1]].end, k+d.rank);
float x_dot_r = 0.;
- GD::foreach_feature<float,GD::vec_add>(all.reg.weight_vector, all.reg.weight_mask, ec.atomics[(int)(*i)[1]].begin, ec.atomics[(int)(*i)[1]].end, x_dot_r, k+all.rank);
+ GD::foreach_feature<float,GD::vec_add>(all.reg.weight_vector, all.reg.weight_mask, ec.atomics[(int)(*i)[1]].begin, ec.atomics[(int)(*i)[1]].end, x_dot_r, k+d.rank);
prediction += x_dot_l * x_dot_r;
@@ -146,7 +156,7 @@ float mf_predict(vw& all, example& ec)
ec.loss = all.loss->getLoss(all.sd, ec.pred.scalar, ld.label) * ld.weight;
if (all.audit)
- mf_print_audit_features(all, ec, 0);
+ mf_print_audit_features(d, ec, 0);
return ec.pred.scalar;
}
@@ -158,55 +168,55 @@ void sd_offset_update(weight* weights, size_t mask, feature* begin, feature* end
weights[(f->weight_index + offset) & mask] += update * f->x - regularization * weights[(f->weight_index + offset) & mask];
}
-void mf_train(vw& all, example& ec)
-{
- weight* weights = all.reg.weight_vector;
- size_t mask = all.reg.weight_mask;
- label_data& ld = ec.l.simple;
-
- // use final prediction to get update size
+ void mf_train(gdmf& d, example& ec)
+ {
+ vw& all = *d.all;
+ weight* weights = all.reg.weight_vector;
+ size_t mask = all.reg.weight_mask;
+ label_data& ld = ec.l.simple;
+
+ // use final prediction to get update size
// update = eta_t*(y-y_hat) where eta_t = eta/(3*t^p) * importance weight
- float eta_t = all.eta/pow(ec.example_t,all.power_t) / 3.f * ld.weight;
- float update = all.loss->getUpdate(ec.pred.scalar, ld.label, eta_t, 1.); //ec.total_sum_feat_sq);
-
- float regularization = eta_t * all.l2_lambda;
-
- // linear update
- for (unsigned char* i = ec.indices.begin; i != ec.indices.end; i++)
- sd_offset_update(weights, mask, ec.atomics[*i].begin, ec.atomics[*i].end, 0, update, regularization);
-
- // quadratic update
- for (vector<string>::iterator i = all.pairs.begin(); i != all.pairs.end();i++)
- {
- if (ec.atomics[(int)(*i)[0]].size() > 0 && ec.atomics[(int)(*i)[1]].size() > 0)
- {
-
- // update l^k weights
- for (size_t k = 1; k <= all.rank; k++)
- {
- // r^k \cdot x_r
- float r_dot_x = ec.topic_predictions[2*k];
- // l^k <- l^k + update * (r^k \cdot x_r) * x_l
- sd_offset_update(weights, mask, ec.atomics[(int)(*i)[0]].begin, ec.atomics[(int)(*i)[0]].end, k, update*r_dot_x, regularization);
- }
-
- // update r^k weights
- for (size_t k = 1; k <= all.rank; k++)
- {
- // l^k \cdot x_l
- float l_dot_x = ec.topic_predictions[2*k-1];
- // r^k <- r^k + update * (l^k \cdot x_l) * x_r
- sd_offset_update(weights, mask, ec.atomics[(int)(*i)[1]].begin, ec.atomics[(int)(*i)[1]].end, k+all.rank, update*l_dot_x, regularization);
- }
-
- }
- }
- if (all.triples.begin() != all.triples.end()) {
- cerr << "cannot use triples in matrix factorization" << endl;
- throw exception();
- }
-}
-
+ float eta_t = all.eta/pow(ec.example_t,all.power_t) / 3.f * ld.weight;
+ float update = all.loss->getUpdate(ec.pred.scalar, ld.label, eta_t, 1.); //ec.total_sum_feat_sq);
+
+ float regularization = eta_t * all.l2_lambda;
+
+ // linear update
+ for (unsigned char* i = ec.indices.begin; i != ec.indices.end; i++)
+ sd_offset_update(weights, mask, ec.atomics[*i].begin, ec.atomics[*i].end, 0, update, regularization);
+
+ // quadratic update
+ for (vector<string>::iterator i = all.pairs.begin(); i != all.pairs.end();i++)
+ {
+ if (ec.atomics[(int)(*i)[0]].size() > 0 && ec.atomics[(int)(*i)[1]].size() > 0)
+ {
+
+ // update l^k weights
+ for (size_t k = 1; k <= d.rank; k++)
+ {
+ // r^k \cdot x_r
+ float r_dot_x = ec.topic_predictions[2*k];
+ // l^k <- l^k + update * (r^k \cdot x_r) * x_l
+ sd_offset_update(weights, mask, ec.atomics[(int)(*i)[0]].begin, ec.atomics[(int)(*i)[0]].end, k, update*r_dot_x, regularization);
+ }
+ // update r^k weights
+ for (size_t k = 1; k <= d.rank; k++)
+ {
+ // l^k \cdot x_l
+ float l_dot_x = ec.topic_predictions[2*k-1];
+ // r^k <- r^k + update * (l^k \cdot x_l) * x_r
+ sd_offset_update(weights, mask, ec.atomics[(int)(*i)[1]].begin, ec.atomics[(int)(*i)[1]].end, k+d.rank, update*l_dot_x, regularization);
+ }
+
+ }
+ }
+ if (all.triples.begin() != all.triples.end()) {
+ cerr << "cannot use triples in matrix factorization" << endl;
+ throw exception();
+ }
+ }
+
void save_load(gdmf& d, io_buf& model_file, bool read, bool text)
{
vw* all = d.all;
@@ -231,7 +241,7 @@ void mf_train(vw& all, example& ec)
do
{
brw = 0;
- size_t K = all->rank*2+1;
+ size_t K = d.rank*2+1;
text_len = sprintf(buff, "%d ", i);
brw += bin_text_read_write_fixed(model_file,(char *)&i, sizeof (i),
@@ -273,19 +283,16 @@ void mf_train(vw& all, example& ec)
}
void predict(gdmf& d, base_learner& base, example& ec)
- {
- vw* all = d.all;
-
- mf_predict(*all,ec);
+ { mf_predict(d,ec);
}
void learn(gdmf& d, base_learner& base, example& ec)
{
- vw* all = d.all;
+ vw& all = *d.all;
- predict(d, base, ec);
- if (all->training && ec.l.simple.label != FLT_MAX)
- mf_train(*all, ec);
+ mf_predict(d, ec);
+ if (all.training && ec.l.simple.label != FLT_MAX)
+ mf_train(d, ec);
}
base_learner* setup(vw& all, po::variables_map& vm)
@@ -294,16 +301,16 @@ void mf_train(vw& all, example& ec)
opts.add_options()
("rank", po::value<uint32_t>(), "rank for matrix factorization.");
vm = add_options(all, opts);
- if(!vm.count("gdmf"))
+ if(!vm.count("rank"))
return NULL;
- else
- all.rank = vm["gdmf"].as<uint32_t>();
gdmf& data = calloc_or_die<gdmf>();
data.all = &all;
+ data.rank = vm["rank"].as<uint32_t>();
+ *all.file_options << " --rank " << data.rank;
// store linear + 2*rank weights per index, round up to power of two
- float temp = ceilf(logf((float)(all.rank*2+1)) / logf (2.f));
+ float temp = ceilf(logf((float)(data.rank*2+1)) / logf (2.f));
all.reg.stride_shift = (size_t) temp;
all.random_weights = true;
diff --git a/vowpalwabbit/global_data.cc b/vowpalwabbit/global_data.cc
index bc869477..243e8657 100644
--- a/vowpalwabbit/global_data.cc
+++ b/vowpalwabbit/global_data.cc
@@ -271,7 +271,6 @@ vw::vw()
power_t = 0.5;
eta = 0.5; //default learning rate for normalized adaptive updates, this is switched to 10 by default for the other updates (see parse_args.cc)
numpasses = 1;
- rank = 0;
final_prediction_sink.begin = final_prediction_sink.end=final_prediction_sink.end_array = NULL;
raw_prediction = -1;
diff --git a/vowpalwabbit/global_data.h b/vowpalwabbit/global_data.h
index 6937c181..09ff643c 100644
--- a/vowpalwabbit/global_data.h
+++ b/vowpalwabbit/global_data.h
@@ -263,7 +263,6 @@ struct vw {
std::string span_server;
size_t length () { return ((size_t)1) << num_bits; };
- uint32_t rank;
v_array<LEARNER::base_learner* (*)(vw&, po::variables_map&)> reduction_stack;
diff --git a/vowpalwabbit/kernel_svm.cc b/vowpalwabbit/kernel_svm.cc
index a8773d64..272be528 100644
--- a/vowpalwabbit/kernel_svm.cc
+++ b/vowpalwabbit/kernel_svm.cc
@@ -795,8 +795,8 @@ namespace KSVM
opts.add_options()
("ksvm", "kernel svm")
("reprocess", po::value<size_t>(), "number of reprocess steps for LASVM")
- ("active", "do active learning")
- ("active_c", po::value<double>(), "parameter for query prob")
+ // ("active", "do active learning")
+ //("active_c", po::value<double>(), "parameter for query prob")
("pool_greedy", "use greedy selection on mini pools")
("para_active", "do parallel active learning")
("pool_size", po::value<size_t>(), "size of pools for active learning")
diff --git a/vowpalwabbit/nn.cc b/vowpalwabbit/nn.cc
index a7079c95..44876e67 100644
--- a/vowpalwabbit/nn.cc
+++ b/vowpalwabbit/nn.cc
@@ -365,8 +365,10 @@ CONVERSE: // That's right, I'm using goto. So sue me.
n.xsubi = vm["random_seed"].as<size_t>();
n.save_xsubi = n.xsubi;
- n.increment = all.l->increment;//Indexing of output layer is odd.
- learner<nn>& l = init_learner(&n, setup_base(all,vm), predict_or_learn<true>,
+
+ base_learner* base = setup_base(all,vm);
+ n.increment = base->increment;//Indexing of output layer is odd.
+ learner<nn>& l = init_learner(&n, base, predict_or_learn<true>,
predict_or_learn<false>, n.k+1);
l.set_finish(finish);
l.set_finish_example(finish_example);
diff --git a/vowpalwabbit/parse_args.cc b/vowpalwabbit/parse_args.cc
index 0781830c..00b2a1d6 100644
--- a/vowpalwabbit/parse_args.cc
+++ b/vowpalwabbit/parse_args.cc
@@ -884,8 +884,6 @@ vw* parse_args(int argc, char *argv[])
cerr << "power_t = " << all->power_t << endl;
if (all->numpasses > 1)
cerr << "decay_learning_rate = " << all->eta_decay_rate << endl;
- if (all->rank > 0)
- cerr << "rank = " << all->rank << endl;
}
parse_output_preds(*all, vm);
diff --git a/vowpalwabbit/parse_regressor.cc b/vowpalwabbit/parse_regressor.cc
index def3a8de..6e7cf27e 100644
--- a/vowpalwabbit/parse_regressor.cc
+++ b/vowpalwabbit/parse_regressor.cc
@@ -164,11 +164,6 @@ void save_load_header(vw& all, io_buf& model_file, bool read, bool text)
"", read,
"\n",1, text);
- text_len = sprintf(buff, "rank:%d\n", (int)all.rank);
- bin_text_read_write_fixed(model_file,(char*)&all.rank, sizeof(all.rank),
- "", read,
- buff,text_len, text);
-
text_len = sprintf(buff, "lda:%d\n", (int)all.lda);
bin_text_read_write_fixed(model_file,(char*)&all.lda, sizeof(all.lda),
"", read,
diff --git a/vowpalwabbit/parser.cc b/vowpalwabbit/parser.cc
index 44055bab..65596402 100644
--- a/vowpalwabbit/parser.cc
+++ b/vowpalwabbit/parser.cc
@@ -840,37 +840,22 @@ void setup_example(vw& all, example* ae)
ae->total_sum_feat_sq += ae->sum_feat_sq[*i];
}
- if (all.rank == 0) {
- for (vector<string>::iterator i = all.pairs.begin(); i != all.pairs.end();i++)
- {
- ae->num_features
- += ae->atomics[(int)(*i)[0]].size()
- *ae->atomics[(int)(*i)[1]].size();
- ae->total_sum_feat_sq += ae->sum_feat_sq[(int)(*i)[0]]*ae->sum_feat_sq[(int)(*i)[1]];
- }
-
- for (vector<string>::iterator i = all.triples.begin(); i != all.triples.end();i++)
- {
- ae->num_features
- += ae->atomics[(int)(*i)[0]].size()
- *ae->atomics[(int)(*i)[1]].size()
- *ae->atomics[(int)(*i)[2]].size();
- ae->total_sum_feat_sq += ae->sum_feat_sq[(int)(*i)[0]] * ae->sum_feat_sq[(int)(*i)[1]] * ae->sum_feat_sq[(int)(*i)[2]];
- }
-
- } else {
- for (vector<string>::iterator i = all.pairs.begin(); i != all.pairs.end();i++)
- {
- ae->num_features += ae->atomics[(int)(*i)[0]].size() * all.rank;
- ae->num_features += ae->atomics[(int)(*i)[1]].size() * all.rank;
- }
- for (vector<string>::iterator i = all.triples.begin(); i != all.triples.end();i++)
- {
- ae->num_features += ae->atomics[(int)(*i)[0]].size() * all.rank;
- ae->num_features += ae->atomics[(int)(*i)[1]].size() * all.rank;
- ae->num_features += ae->atomics[(int)(*i)[2]].size() * all.rank;
- }
- }
+ for (vector<string>::iterator i = all.pairs.begin(); i != all.pairs.end();i++)
+ {
+ ae->num_features
+ += ae->atomics[(int)(*i)[0]].size()
+ *ae->atomics[(int)(*i)[1]].size();
+ ae->total_sum_feat_sq += ae->sum_feat_sq[(int)(*i)[0]]*ae->sum_feat_sq[(int)(*i)[1]];
+ }
+
+ for (vector<string>::iterator i = all.triples.begin(); i != all.triples.end();i++)
+ {
+ ae->num_features
+ += ae->atomics[(int)(*i)[0]].size()
+ *ae->atomics[(int)(*i)[1]].size()
+ *ae->atomics[(int)(*i)[2]].size();
+ ae->total_sum_feat_sq += ae->sum_feat_sq[(int)(*i)[0]] * ae->sum_feat_sq[(int)(*i)[1]] * ae->sum_feat_sq[(int)(*i)[2]];
+ }
}
}
diff --git a/vowpalwabbit/search.cc b/vowpalwabbit/search.cc
index 5e782ea1..5bc7c797 100644
--- a/vowpalwabbit/search.cc
+++ b/vowpalwabbit/search.cc
@@ -1956,7 +1956,10 @@ namespace Search {
}
all.p->emptylines_separate_examples = true;
- if (!vm.count("csoaa") && !vm.count("csoaa_ldf") && !vm.count("wap_ldf") && !vm.count("cb"))
+ if (count(all.args.begin(), all.args.end(),"--csoaa") == 0
+ && count(all.args.begin(), all.args.end(),"--csoaa_ldf") == 0
+ && count(all.args.begin(), all.args.end(),"--wap_ldf") == 0
+ && count(all.args.begin(), all.args.end(),"--cb") == 0)
{
all.args.push_back("--csoaa");
stringstream ss;