Skip to content

Commit 9d0fec8

Browse files
author
Ivan Matantsev
committed
address comments and entry points test
1 parent cae5c9b commit 9d0fec8

File tree

4 files changed

+30
-23
lines changed

4 files changed

+30
-23
lines changed

docs/samples/Microsoft.ML.Samples/Dynamic/Trainers/BinaryClassification/AveragedPerceptronWithOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static void Example()
2525
{
2626
LossFunction = new SmoothedHingeLoss.Options(),
2727
LearningRate = 0.1f,
28-
LazyUpdates = false,
28+
LazyUpdate = false,
2929
RecencyGain = 0.1f,
3030
NumberOfIterations = 10
3131
};

src/Microsoft.ML.StandardLearners/Standard/Online/AveragedLinear.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public abstract class AveragedLinearOptions : OnlineLinearOptions
5757
/// <see langword="false" /> to update averaged weights on every example.
5858
/// Default is <see langword="true" />.
5959
/// </value>
60-
[Argument(ArgumentType.AtMostOnce, HelpText = "Instead of updating averaged weights on every example, only update when loss is nonzero", ShortName = "lazy")]
61-
public bool LazyUpdates = true;
60+
[Argument(ArgumentType.AtMostOnce, HelpText = "Instead of updating averaged weights on every example, only update when loss is nonzero", ShortName = "lazy,DoLazyUpdates")]
61+
public bool LazyUpdate = true;
6262

6363
/// <summary>
6464
/// The L2 weight for <a href='tmpurl_regularization'>regularization</a>.
@@ -85,7 +85,7 @@ public abstract class AveragedLinearOptions : OnlineLinearOptions
8585
/// <see langword="false" /> means <see cref="RecencyGain"/> is additive.
8686
/// Default is <see langword="false" />.
8787
/// </value>
88-
[Argument(ArgumentType.AtMostOnce, HelpText = "Whether Recency Gain is multiplicative (vs. additive)", ShortName = "rgm")]
88+
[Argument(ArgumentType.AtMostOnce, HelpText = "Whether Recency Gain is multiplicative (vs. additive)", ShortName = "rgm,RecencyGainMulti")]
8989
public bool RecencyGainMultiplicative = false;
9090

9191
/// <summary>
@@ -186,7 +186,7 @@ public override void FinishIteration(IChannel ch)
186186
// Finalize things
187187
if (Averaged)
188188
{
189-
if (_args.LazyUpdates && NumNoUpdates > 0)
189+
if (_args.LazyUpdate && NumNoUpdates > 0)
190190
{
191191
// Update the total weights to include the final loss=0 updates
192192
VectorUtils.AddMult(in Weights, NumNoUpdates * WeightsScale, ref TotalWeights);
@@ -224,7 +224,7 @@ public override void ProcessDataInstance(IChannel ch, in VBuffer<float> feat, fl
224224
if (loss != 0 || _args.L2Regularization > 0)
225225
{
226226
// If doing lazy weights, we need to update the totalWeights and totalBias before updating weights/bias
227-
if (_args.LazyUpdates && _args.Averaged && NumNoUpdates > 0 && TotalMultipliers * _args.AveragedTolerance <= PendingMultipliers)
227+
if (_args.LazyUpdate && _args.Averaged && NumNoUpdates > 0 && TotalMultipliers * _args.AveragedTolerance <= PendingMultipliers)
228228
{
229229
VectorUtils.AddMult(in Weights, NumNoUpdates * WeightsScale, ref TotalWeights);
230230
TotalBias += Bias * NumNoUpdates * WeightsScale;
@@ -251,7 +251,7 @@ public override void ProcessDataInstance(IChannel ch, in VBuffer<float> feat, fl
251251
// Add to averaged weights and increment the count.
252252
if (Averaged)
253253
{
254-
if (!_args.LazyUpdates)
254+
if (!_args.LazyUpdate)
255255
IncrementAverageNonLazy();
256256
else
257257
NumNoUpdates++;
@@ -307,7 +307,7 @@ private protected AveragedLinearTrainer(AveragedLinearOptions options, IHostEnvi
307307
Contracts.CheckUserArg(options.RecencyGain >= 0, nameof(options.RecencyGain), UserErrorNonNegative);
308308
Contracts.CheckUserArg(options.AveragedTolerance >= 0, nameof(options.AveragedTolerance), UserErrorNonNegative);
309309
// Verify user didn't specify parameters that conflict
310-
Contracts.Check(!options.LazyUpdates || !options.RecencyGainMultiplicative && options.RecencyGain == 0, "Cannot have both recency gain and lazy updates.");
310+
Contracts.Check(!options.LazyUpdate || !options.RecencyGainMultiplicative && options.RecencyGain == 0, "Cannot have both recency gain and lazy updates.");
311311

312312
AveragedLinearTrainerOptions = options;
313313
}

src/Microsoft.ML.StandardLearners/Standard/Online/LinearSvm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public sealed class Options : OnlineLinearOptions
6969
/// <summary>
7070
/// Column to use for example weight.
7171
/// </summary>
72-
[Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for example weight", ShortName = "weight", SortOrder = 4, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)]
72+
[Argument(ArgumentType.AtMostOnce, HelpText = "Column to use for example weight", ShortName = "weight,WeightColumn", SortOrder = 4, Visibility = ArgumentAttribute.VisibilityType.EntryPointsOnly)]
7373
public string ExampleWeightColumnName = null;
7474
}
7575

test/BaselineOutput/Common/EntryPoints/core_manifest.json

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4286,11 +4286,12 @@
42864286
}
42874287
},
42884288
{
4289-
"Name": "L2RegularizerWeight",
4289+
"Name": "L2Regularization",
42904290
"Type": "Float",
42914291
"Desc": "L2 Regularization Weight",
42924292
"Aliases": [
4293-
"reg"
4293+
"reg",
4294+
"L2RegularizerWeight"
42944295
],
42954296
"Required": false,
42964297
"SortOrder": 50.0,
@@ -4377,11 +4378,12 @@
43774378
"Default": null
43784379
},
43794380
{
4380-
"Name": "DoLazyUpdates",
4381+
"Name": "LazyUpdate",
43814382
"Type": "Bool",
43824383
"Desc": "Instead of updating averaged weights on every example, only update when loss is nonzero",
43834384
"Aliases": [
4384-
"lazy"
4385+
"lazy",
4386+
"DoLazyUpdates"
43854387
],
43864388
"Required": false,
43874389
"SortOrder": 150.0,
@@ -4401,11 +4403,12 @@
44014403
"Default": 0.0
44024404
},
44034405
{
4404-
"Name": "RecencyGainMulti",
4406+
"Name": "RecencyGainMultiplicative",
44054407
"Type": "Bool",
44064408
"Desc": "Whether Recency Gain is multiplicative (vs. additive)",
44074409
"Aliases": [
4408-
"rgm"
4410+
"rgm",
4411+
"RecencyGainMulti"
44094412
],
44104413
"Required": false,
44114414
"SortOrder": 150.0,
@@ -13113,11 +13116,12 @@
1311313116
"Default": "Label"
1311413117
},
1311513118
{
13116-
"Name": "WeightColumn",
13119+
"Name": "ExampleWeightColumnName",
1311713120
"Type": "String",
1311813121
"Desc": "Column to use for example weight",
1311913122
"Aliases": [
13120-
"weight"
13123+
"weight",
13124+
"WeightColumn"
1312113125
],
1312213126
"Required": false,
1312313127
"SortOrder": 4.0,
@@ -14214,11 +14218,12 @@
1421414218
}
1421514219
},
1421614220
{
14217-
"Name": "L2RegularizerWeight",
14221+
"Name": "L2Regularization",
1421814222
"Type": "Float",
1421914223
"Desc": "L2 Regularization Weight",
1422014224
"Aliases": [
14221-
"reg"
14225+
"reg",
14226+
"L2RegularizerWeight"
1422214227
],
1422314228
"Required": false,
1422414229
"SortOrder": 50.0,
@@ -14282,11 +14287,12 @@
1428214287
"Default": null
1428314288
},
1428414289
{
14285-
"Name": "DoLazyUpdates",
14290+
"Name": "LazyUpdate",
1428614291
"Type": "Bool",
1428714292
"Desc": "Instead of updating averaged weights on every example, only update when loss is nonzero",
1428814293
"Aliases": [
14289-
"lazy"
14294+
"lazy",
14295+
"DoLazyUpdates"
1429014296
],
1429114297
"Required": false,
1429214298
"SortOrder": 150.0,
@@ -14306,11 +14312,12 @@
1430614312
"Default": 0.0
1430714313
},
1430814314
{
14309-
"Name": "RecencyGainMulti",
14315+
"Name": "RecencyGainMultiplicative",
1431014316
"Type": "Bool",
1431114317
"Desc": "Whether Recency Gain is multiplicative (vs. additive)",
1431214318
"Aliases": [
14313-
"rgm"
14319+
"rgm",
14320+
"RecencyGainMulti"
1431414321
],
1431514322
"Required": false,
1431614323
"SortOrder": 150.0,

0 commit comments

Comments
 (0)