diff options
author | John Langford <jl@nyclamp.(none)> | 2014-05-01 22:39:34 +0400 |
---|---|---|
committer | John Langford <jl@nyclamp.(none)> | 2014-05-01 22:39:34 +0400 |
commit | fb7c1f55964e4f04d4dd829cc59e8a9244478a13 (patch) | |
tree | 85e1b4437298bd86056f6ba279cc458fea97e3ee /vowpalwabbit/parse_args.cc | |
parent | 2b46732522fe912835cca0252af3bfdd4720f2c0 (diff) |
debug commit
Diffstat (limited to 'vowpalwabbit/parse_args.cc')
-rw-r--r-- | vowpalwabbit/parse_args.cc | 117 |
1 files changed, 19 insertions, 98 deletions
diff --git a/vowpalwabbit/parse_args.cc b/vowpalwabbit/parse_args.cc index b6afabae..0a4b94da 100644 --- a/vowpalwabbit/parse_args.cc +++ b/vowpalwabbit/parse_args.cc @@ -381,11 +381,11 @@ vw* parse_args(int argc, char *argv[]) msrand48(random_seed); if (vm.count("active_simulation")) - all->active_simulation = true; - + all->active_simulation = true; + if (vm.count("active_learning") && !all->active_simulation) all->active = true; - + if (vm.count("no_stdin")) all->stdin_off = true; @@ -406,42 +406,6 @@ vw* parse_args(int argc, char *argv[]) throw exception(); } - all->reg.stride_shift = 2; //use stride of 4 for default invariant normalized adaptive updates - //if the user specified anything in sgd,adaptive,invariant,normalized, we turn off default update rules and use whatever user specified - if( (all->rank > 0 && !vm.count("new_mf")) || !all->training || ( ( vm.count("sgd") || vm.count("adaptive") || vm.count("invariant") || vm.count("normalized") ) && !vm.count("exact_adaptive_norm")) ) - { - all->adaptive = all->training && vm.count("adaptive") && (all->rank == 0 && !vm.count("new_mf")); - all->invariant_updates = all->training && vm.count("invariant"); - all->normalized_updates = all->training && vm.count("normalized") && (all->rank == 0 && !vm.count("new_mf")); - - all->reg.stride_shift = 0; - - if( all->adaptive ) all->reg.stride_shift += 1; - else all->normalized_idx = 1; //store per feature norm at 1 index offset from weight value instead of 2 - - if( all->normalized_updates ) all->reg.stride_shift += 1; - - if(!vm.count("learning_rate") && !vm.count("l") && !(all->adaptive && all->normalized_updates)) - if (all->lda == 0) - all->eta = 10; //default learning rate to 10 for non default update rule - - //if not using normalized or adaptive, default initial_t to 1 instead of 0 - if(!all->adaptive && !all->normalized_updates && !vm.count("initial_t")) { - all->sd->t = 1.f; - all->sd->weighted_unlabeled_examples = 1.f; - all->initial_t = 1.f; - } - if (vm.count("feature_mask")){ - if(all->reg.stride_shift == 0){ - all->reg.stride_shift += 1;//if --sgd, stride->2 and use the second position as mask - all->feature_mask_idx = 1; - } - else if(all->reg.stride_shift == 1){ - all->reg.stride_shift += 1;//if either normalized or adaptive, stride->4, mask_idx is still 3 - } - } - } - if (all->l1_lambda < 0.) { cerr << "l1_lambda should be nonnegative: resetting from " << all->l1_lambda << " to 0" << endl; all->l1_lambda = 0.; @@ -460,19 +424,12 @@ vw* parse_args(int argc, char *argv[]) cerr << "using l2 regularization = " << all->l2_lambda << endl; } - all->l = GD::setup(*all, vm); - all->scorer = all->l; - - if (vm.count("bfgs") || vm.count("conjugate_gradient")) - all->l = BFGS::setup(*all, to_pass_further, vm, vm_file); - if (vm.count("version") || argc == 1) { /* upon direct query for version -- spit it out to stdout */ cout << version.to_string() << "\n"; exit(0); } - if(vm.count("ngram")){ if(vm.count("sort_features")) { @@ -678,50 +635,29 @@ vw* parse_args(int argc, char *argv[]) } } - // (non-reduction) matrix factorization enabled - if (!vm.count("new_mf") && all->rank > 0) { - // 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)); - all->reg.stride_shift = (size_t) temp; - all->random_weights = true; - - if ( vm.count("adaptive") ) - { - cerr << "adaptive is not implemented for matrix factorization" << endl; - throw exception(); - } - if ( vm.count("normalized") ) - { - cerr << "normalized is not implemented for matrix factorization" << endl; - throw exception(); - } - if ( vm.count("exact_adaptive_norm") ) - { - cerr << "normalized adaptive updates is not implemented for matrix factorization" << endl; - throw exception(); - } - if (vm.count("bfgs") || vm.count("conjugate_gradient")) - { - cerr << "bfgs is not implemented for matrix factorization" << endl; - throw exception(); - } - - //default initial_t to 1 instead of 0 - if(!vm.count("initial_t")) { - all->sd->t = 1.f; - all->sd->weighted_unlabeled_examples = 1.f; - all->initial_t = 1.f; - } - } - if (vm.count("noconstant")) all->add_constant = false; //if (vm.count("nonormalize")) // all->nonormalize = true; - if (vm.count("lda")) + if (!vm.count("bfgs") && !vm.count("conjugate_gradient") && !vm.count("noop") && !vm.count("lda") && !vm.count("print") && !vm.count("new_mf") && !vm.count("sendto")) + { + all->l = GD::setup(*all, vm); + all->scorer = all->l; + } + else if (vm.count("bfgs") || vm.count("conjugate_gradient")) + all->l = BFGS::setup(*all, to_pass_further, vm, vm_file); + else if (vm.count("lda")) all->l = LDA::setup(*all, to_pass_further, vm); + else if (vm.count("noop")) + all->l = NOOP::setup(*all); + else if (vm.count("print")) + all->l = PRINT::setup(*all); + else if (!vm.count("new_mf") && all->rank > 0) + all->l = GDMF::setup(*all, vm); + else if (vm.count("sendto")) + all->l = SENDER::setup(*all, vm, all->pairs); if (!vm.count("lda") && !all->adaptive && !all->normalized_updates) all->eta *= powf((float)(all->sd->t), all->power_t); @@ -757,18 +693,6 @@ vw* parse_args(int argc, char *argv[]) if(vm.count("quantile_tau")) loss_parameter = vm["quantile_tau"].as<float>(); - if (vm.count("noop")) - all->l = NOOP::setup(*all); - - if (vm.count("print")) - { - all->l = PRINT::setup(*all); - all->reg.stride_shift = 0; - } - - if (!vm.count("new_mf") && all->rank > 0) - all->l = GDMF::setup(*all); - all->loss = getLossFunction(all, loss_function, (float)loss_parameter); if (pow((double)all->eta_decay_rate, (double)all->numpasses) < 0.0001 ) @@ -834,9 +758,6 @@ vw* parse_args(int argc, char *argv[]) all->audit = true; } - if (vm.count("sendto")) - all->l = SENDER::setup(*all, vm, all->pairs); - // Need to see if we have to load feature mask first or second. // -i and -mask are from same file, load -i file first so mask can use it if (vm.count("feature_mask") && vm.count("initial_regressor") |