Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Averaged Perceptron default value #5586

Merged
merged 3 commits into from
Jan 21, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Microsoft.ML.Numeric;
using Microsoft.ML.Runtime;
using Microsoft.ML.Trainers;
using static Microsoft.ML.Trainers.AveragedLinearOptions;

[assembly: LoadableClass(AveragedPerceptronTrainer.Summary, typeof(AveragedPerceptronTrainer), typeof(AveragedPerceptronTrainer.Options),
new[] { typeof(SignatureBinaryClassifierTrainer), typeof(SignatureTrainer), typeof(SignatureFeatureScorerTrainer) },
Expand Down Expand Up @@ -76,6 +77,11 @@ public sealed class AveragedPerceptronTrainer : AveragedLinearTrainer<BinaryPred

private readonly Options _args;

internal class AveragedPerceptronDefault : AveragedDefault
michaelgsharp marked this conversation as resolved.
Show resolved Hide resolved
{
public new const int NumberOfIterations = 10;
michaelgsharp marked this conversation as resolved.
Show resolved Hide resolved
}

/// <summary>
/// Options for the <see cref="AveragedPerceptronTrainer"/> as used in
/// <see cref="Microsoft.ML.StandardTrainersCatalog.AveragedPerceptron(BinaryClassificationCatalog.BinaryClassificationTrainers, Options)"/>.
Expand All @@ -84,7 +90,7 @@ public sealed class Options : AveragedLinearOptions
{
public Options()
{
NumberOfIterations = 10;
NumberOfIterations = AveragedPerceptronDefault.NumberOfIterations;
}

/// <summary>
Expand Down Expand Up @@ -166,10 +172,10 @@ internal AveragedPerceptronTrainer(IHostEnvironment env,
string labelColumnName = DefaultColumnNames.Label,
string featureColumnName = DefaultColumnNames.Features,
IClassificationLoss lossFunction = null,
float learningRate = Options.AveragedDefault.LearningRate,
bool decreaseLearningRate = Options.AveragedDefault.DecreaseLearningRate,
float l2Regularization = Options.AveragedDefault.L2Regularization,
int numberOfIterations = Options.AveragedDefault.NumberOfIterations)
float learningRate = AveragedPerceptronDefault.LearningRate,
bool decreaseLearningRate = AveragedPerceptronDefault.DecreaseLearningRate,
float l2Regularization = AveragedPerceptronDefault.L2Regularization,
int numberOfIterations = AveragedPerceptronDefault.NumberOfIterations)
: this(env, new Options
{
LabelColumnName = labelColumnName,
Expand Down