Skip to content

Commit 4c83066

Browse files
authored
Renaming IterationsToRemember to HistorySize for L-BFGS learners. (#2894)
* Renaming IterationsToRemember to HistorySize for L-BFGS learners.
1 parent 8bcc03c commit 4c83066

File tree

7 files changed

+36
-36
lines changed

7 files changed

+36
-36
lines changed

src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LbfgsPredictorBase.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public abstract class OptionsBase : TrainerInputBaseWithWeight
5454
ShortName = "m, MemorySize", SortOrder = 50)]
5555
[TGUI(Description = "Memory size for L-BFGS", SuggestedSweeps = "5,20,50")]
5656
[TlcModule.SweepableDiscreteParamAttribute("MemorySize", new object[] { 5, 20, 50 })]
57-
public int IterationsToRemember = Defaults.IterationsToRemember;
57+
public int HistorySize = Defaults.HistorySize;
5858

5959
/// <summary>
6060
/// Number of iterations.
@@ -121,7 +121,7 @@ internal static class Defaults
121121
public const float L2Regularization = 1;
122122
public const float L1Regularization = 1;
123123
public const float OptimizationTolerance = 1e-7f;
124-
public const int IterationsToRemember = 20;
124+
public const int HistorySize = 20;
125125
public const int NumberOfIterations = int.MaxValue;
126126
public const bool EnforceNonNegativity = false;
127127
}
@@ -192,7 +192,7 @@ internal LbfgsTrainerBase(IHostEnvironment env,
192192
L1Regularization = l1Weight,
193193
L2Regularization = l2Weight,
194194
OptmizationTolerance = optimizationTolerance,
195-
IterationsToRemember = memorySize,
195+
HistorySize = memorySize,
196196
EnforceNonNegativity = enforceNoNegativity
197197
},
198198
labelColumn)
@@ -220,20 +220,20 @@ internal LbfgsTrainerBase(IHostEnvironment env,
220220
Host.CheckUserArg(LbfgsTrainerOptions.L2Regularization >= 0, nameof(LbfgsTrainerOptions.L2Regularization), "Must be non-negative");
221221
Host.CheckUserArg(LbfgsTrainerOptions.L1Regularization >= 0, nameof(LbfgsTrainerOptions.L1Regularization), "Must be non-negative");
222222
Host.CheckUserArg(LbfgsTrainerOptions.OptmizationTolerance > 0, nameof(LbfgsTrainerOptions.OptmizationTolerance), "Must be positive");
223-
Host.CheckUserArg(LbfgsTrainerOptions.IterationsToRemember > 0, nameof(LbfgsTrainerOptions.IterationsToRemember), "Must be positive");
223+
Host.CheckUserArg(LbfgsTrainerOptions.HistorySize > 0, nameof(LbfgsTrainerOptions.HistorySize), "Must be positive");
224224
Host.CheckUserArg(LbfgsTrainerOptions.NumberOfIterations > 0, nameof(LbfgsTrainerOptions.NumberOfIterations), "Must be positive");
225225
Host.CheckUserArg(LbfgsTrainerOptions.StochasticGradientDescentInitilaizationTolerance >= 0, nameof(LbfgsTrainerOptions.StochasticGradientDescentInitilaizationTolerance), "Must be non-negative");
226226
Host.CheckUserArg(LbfgsTrainerOptions.NumberOfThreads == null || LbfgsTrainerOptions.NumberOfThreads.Value >= 0, nameof(LbfgsTrainerOptions.NumberOfThreads), "Must be non-negative");
227227

228228
Host.CheckParam(!(LbfgsTrainerOptions.L2Regularization < 0), nameof(LbfgsTrainerOptions.L2Regularization), "Must be non-negative, if provided.");
229229
Host.CheckParam(!(LbfgsTrainerOptions.L1Regularization < 0), nameof(LbfgsTrainerOptions.L1Regularization), "Must be non-negative, if provided");
230230
Host.CheckParam(!(LbfgsTrainerOptions.OptmizationTolerance <= 0), nameof(LbfgsTrainerOptions.OptmizationTolerance), "Must be positive, if provided.");
231-
Host.CheckParam(!(LbfgsTrainerOptions.IterationsToRemember <= 0), nameof(LbfgsTrainerOptions.IterationsToRemember), "Must be positive, if provided.");
231+
Host.CheckParam(!(LbfgsTrainerOptions.HistorySize <= 0), nameof(LbfgsTrainerOptions.HistorySize), "Must be positive, if provided.");
232232

233233
L2Weight = LbfgsTrainerOptions.L2Regularization;
234234
L1Weight = LbfgsTrainerOptions.L1Regularization;
235235
OptTol = LbfgsTrainerOptions.OptmizationTolerance;
236-
MemorySize =LbfgsTrainerOptions.IterationsToRemember;
236+
MemorySize =LbfgsTrainerOptions.HistorySize;
237237
MaxIterations = LbfgsTrainerOptions.NumberOfIterations;
238238
SgdInitializationTolerance = LbfgsTrainerOptions.StochasticGradientDescentInitilaizationTolerance;
239239
Quiet = LbfgsTrainerOptions.Quiet;
@@ -272,7 +272,7 @@ private static TOptions ArgsInit(string featureColumn, SchemaShape.Column labelC
272272
L1Regularization = l1Weight,
273273
L2Regularization = l2Weight,
274274
OptmizationTolerance = optimizationTolerance,
275-
IterationsToRemember = memorySize,
275+
HistorySize = memorySize,
276276
EnforceNonNegativity = enforceNoNegativity
277277
};
278278

src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/LogisticRegression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ internal LogisticRegression(IHostEnvironment env,
8383
float l1Weight = Options.Defaults.L1Regularization,
8484
float l2Weight = Options.Defaults.L2Regularization,
8585
float optimizationTolerance = Options.Defaults.OptimizationTolerance,
86-
int memorySize = Options.Defaults.IterationsToRemember,
86+
int memorySize = Options.Defaults.HistorySize,
8787
bool enforceNoNegativity = Options.Defaults.EnforceNonNegativity)
8888
: base(env, featureColumn, TrainerUtils.MakeBoolScalarLabel(labelColumn), weights,
8989
l1Weight, l2Weight, optimizationTolerance, memorySize, enforceNoNegativity)

src/Microsoft.ML.StandardLearners/Standard/LogisticRegression/MulticlassLogisticRegression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ internal MulticlassLogisticRegression(IHostEnvironment env,
9090
float l1Weight = Options.Defaults.L1Regularization,
9191
float l2Weight = Options.Defaults.L2Regularization,
9292
float optimizationTolerance = Options.Defaults.OptimizationTolerance,
93-
int memorySize = Options.Defaults.IterationsToRemember,
93+
int memorySize = Options.Defaults.HistorySize,
9494
bool enforceNoNegativity = Options.Defaults.EnforceNonNegativity)
9595
: base(env, featureColumn, TrainerUtils.MakeU4ScalarColumn(labelColumn), weights, l1Weight, l2Weight, optimizationTolerance, memorySize, enforceNoNegativity)
9696
{

src/Microsoft.ML.StandardLearners/Standard/PoissonRegression/PoissonRegression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ internal PoissonRegression(IHostEnvironment env,
5858
float l1Weight = Options.Defaults.L1Regularization,
5959
float l2Weight = Options.Defaults.L2Regularization,
6060
float optimizationTolerance = Options.Defaults.OptimizationTolerance,
61-
int memorySize = Options.Defaults.IterationsToRemember,
61+
int memorySize = Options.Defaults.HistorySize,
6262
bool enforceNoNegativity = Options.Defaults.EnforceNonNegativity)
6363
: base(env, featureColumn, TrainerUtils.MakeR4ScalarColumn(labelColumn), weights,
6464
l1Weight, l2Weight, optimizationTolerance, memorySize, enforceNoNegativity)

src/Microsoft.ML.StandardLearners/StandardLearnersCatalog.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ public static OnlineGradientDescentTrainer OnlineGradientDescent(this Regression
453453
/// <param name="enforceNonNegativity">Enforce non-negative weights.</param>
454454
/// <param name="l1Regularization">Weight of L1 regularization term.</param>
455455
/// <param name="l2Regularization">Weight of L2 regularization term.</param>
456-
/// <param name="iterationsToRemember">Memory size for <see cref="Trainers.LogisticRegression"/>. Low=faster, less accurate.</param>
456+
/// <param name="historySize">Memory size for <see cref="Trainers.LogisticRegression"/>. Low=faster, less accurate.</param>
457457
/// <param name="optimizationTolerance">Threshold for optimizer convergence.</param>
458458
/// <example>
459459
/// <format type="text/markdown">
@@ -469,12 +469,12 @@ public static LogisticRegression LogisticRegression(this BinaryClassificationCat
469469
float l1Regularization = LROptions.Defaults.L1Regularization,
470470
float l2Regularization = LROptions.Defaults.L2Regularization,
471471
float optimizationTolerance = LROptions.Defaults.OptimizationTolerance,
472-
int iterationsToRemember = LROptions.Defaults.IterationsToRemember,
472+
int historySize = LROptions.Defaults.HistorySize,
473473
bool enforceNonNegativity = LROptions.Defaults.EnforceNonNegativity)
474474
{
475475
Contracts.CheckValue(catalog, nameof(catalog));
476476
var env = CatalogUtils.GetEnvironment(catalog);
477-
return new LogisticRegression(env, labelColumnName, featureColumnName, exampleWeightColumnName, l1Regularization, l2Regularization, optimizationTolerance, iterationsToRemember, enforceNonNegativity);
477+
return new LogisticRegression(env, labelColumnName, featureColumnName, exampleWeightColumnName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity);
478478
}
479479

480480
/// <summary>
@@ -501,7 +501,7 @@ public static LogisticRegression LogisticRegression(this BinaryClassificationCat
501501
/// <param name="l1Regularization">Weight of L1 regularization term.</param>
502502
/// <param name="l2Regularization">Weight of L2 regularization term.</param>
503503
/// <param name="optimizationTolerance">Threshold for optimizer convergence.</param>
504-
/// <param name="iterationsToRemember">Memory size for <see cref="Microsoft.ML.Trainers.PoissonRegression"/>. Low=faster, less accurate.</param>
504+
/// <param name="historySize">Memory size for <see cref="Microsoft.ML.Trainers.PoissonRegression"/>. Low=faster, less accurate.</param>
505505
/// <param name="enforceNonNegativity">Enforce non-negative weights.</param>
506506
public static PoissonRegression PoissonRegression(this RegressionCatalog.RegressionTrainers catalog,
507507
string labelColumnName = DefaultColumnNames.Label,
@@ -510,12 +510,12 @@ public static PoissonRegression PoissonRegression(this RegressionCatalog.Regress
510510
float l1Regularization = LROptions.Defaults.L1Regularization,
511511
float l2Regularization = LROptions.Defaults.L2Regularization,
512512
float optimizationTolerance = LROptions.Defaults.OptimizationTolerance,
513-
int iterationsToRemember = LROptions.Defaults.IterationsToRemember,
513+
int historySize = LROptions.Defaults.HistorySize,
514514
bool enforceNonNegativity = LROptions.Defaults.EnforceNonNegativity)
515515
{
516516
Contracts.CheckValue(catalog, nameof(catalog));
517517
var env = CatalogUtils.GetEnvironment(catalog);
518-
return new PoissonRegression(env, labelColumnName, featureColumnName, exampleWeightColumnName, l1Regularization, l2Regularization, optimizationTolerance, iterationsToRemember, enforceNonNegativity);
518+
return new PoissonRegression(env, labelColumnName, featureColumnName, exampleWeightColumnName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity);
519519
}
520520

521521
/// <summary>
@@ -542,7 +542,7 @@ public static PoissonRegression PoissonRegression(this RegressionCatalog.Regress
542542
/// <param name="enforceNonNegativity">Enforce non-negative weights.</param>
543543
/// <param name="l1Regularization">Weight of L1 regularization term.</param>
544544
/// <param name="l2Regularization">Weight of L2 regularization term.</param>
545-
/// <param name="iterationsToRemember">Memory size for <see cref="Microsoft.ML.Trainers.MulticlassLogisticRegression"/>. Low=faster, less accurate.</param>
545+
/// <param name="historySize">Memory size for <see cref="Microsoft.ML.Trainers.MulticlassLogisticRegression"/>. Low=faster, less accurate.</param>
546546
/// <param name="optimizationTolerance">Threshold for optimizer convergence.</param>
547547
public static MulticlassLogisticRegression LogisticRegression(this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog,
548548
string labelColumnName = DefaultColumnNames.Label,
@@ -551,12 +551,12 @@ public static MulticlassLogisticRegression LogisticRegression(this MulticlassCla
551551
float l1Regularization = LROptions.Defaults.L1Regularization,
552552
float l2Regularization = LROptions.Defaults.L2Regularization,
553553
float optimizationTolerance = LROptions.Defaults.OptimizationTolerance,
554-
int iterationsToRemember = LROptions.Defaults.IterationsToRemember,
554+
int historySize = LROptions.Defaults.HistorySize,
555555
bool enforceNonNegativity = LROptions.Defaults.EnforceNonNegativity)
556556
{
557557
Contracts.CheckValue(catalog, nameof(catalog));
558558
var env = CatalogUtils.GetEnvironment(catalog);
559-
return new MulticlassLogisticRegression(env, labelColumnName, featureColumnName, exampleWeightColumnName, l1Regularization, l2Regularization, optimizationTolerance, iterationsToRemember, enforceNonNegativity);
559+
return new MulticlassLogisticRegression(env, labelColumnName, featureColumnName, exampleWeightColumnName, l1Regularization, l2Regularization, optimizationTolerance, historySize, enforceNonNegativity);
560560
}
561561

562562
/// <summary>

0 commit comments

Comments
 (0)