Skip to content

Commit

Permalink
added (hidden) explicit disable_line_search flag to allow user to for…
Browse files Browse the repository at this point in the history
…ce disable line search in all cases
  • Loading branch information
tomasnykodym committed Jan 12, 2015
1 parent 53ab319 commit 7b346d7
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/main/java/hex/glm/GLM2.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public void setTweediePower(double pwr){

@API(help="prior probability for y==1. To be used only for logistic regression iff the data has been sampled and the mean of response does not reflect reality.",filter=Default.class, importance = ParamImportance.EXPERT)
protected double prior = -1; // -1 is magic value for default value which is mean(y) computed on the current dataset

@API(help="disable line search in all cases.",filter=Default.class, importance = ParamImportance.EXPERT, hide = true)
protected boolean disable_line_search = false; // -1 is magic value for default value which is mean(y) computed on the current dataset

private double _iceptAdjust; // adjustment due to the prior

@API(help = "validation folds", filter = Default.class, lmin=0, lmax=100, json=true, importance = ParamImportance.CRITICAL)
Expand Down Expand Up @@ -672,6 +676,8 @@ protected double l1norm(double[] beta){
}
// protected boolean needLineSearch(final double [] beta,double objval, double step){
protected boolean needLineSearch(final GLMIterationTask glmt) {
if(disable_line_search)
return false;
if(_glm.family == Family.gaussian)
return false;
if(glmt._beta == null)
Expand Down Expand Up @@ -820,15 +826,7 @@ public void callback(final GLMIterationTask glmt2) {
final double [] grad = glmt2.gradient(alpha[0],_currentLambda);
if(Utils.hasNaNsOrInfs(grad)){
_failedLineSearch = true;
if(!failedLineSearch) {
getCompleter().addToPendingCount(1);
checkKKTAndComplete(cc,glmt,glmt._beta,true);
LogInfo("Check KKT got NaNs. Taking previous solution");
return;
} else {
// TODO: add warning and break th lambda search? Or throw Exception?
LogInfo("got NaNs/Infs in gradient at lambda " + _currentLambda);
}
// TODO: add warning and break the lambda search? Or throw Exception?
}
glmt._val = glmt2._val;
_lastResult = makeIterationInfo(_iter,glmt2,null,glmt2.gradient(alpha[0],0));
Expand Down

0 comments on commit 7b346d7

Please sign in to comment.