Skip to content

Commit cb3083b

Browse files
fix tests
1 parent e1d5c8f commit cb3083b

File tree

16 files changed

+88
-62
lines changed

16 files changed

+88
-62
lines changed

src/Microsoft.ML.SearchSpace/Converter/NumericOptionConverter.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public override void Write(Utf8JsonWriter writer, UniformNumericOption value, Js
5454
UniformIntOption intOption => new Schema
5555
{
5656
Type = "int",
57-
Default = intOption.SampleFromFeatureSpace(intOption.Default).AsType<double>(),
57+
Default = intOption.SampleFromFeatureSpace(intOption.Default).AsType<int>(),
5858
Min = Convert.ToInt32(intOption.Min),
5959
Max = Convert.ToInt32(intOption.Max),
6060
LogBase = intOption.LogBase,
@@ -70,7 +70,7 @@ public override void Write(Utf8JsonWriter writer, UniformNumericOption value, Js
7070
UniformSingleOption singleOption => new Schema
7171
{
7272
Type = "float",
73-
Default = singleOption.SampleFromFeatureSpace(singleOption.Default).AsType<double>(),
73+
Default = singleOption.SampleFromFeatureSpace(singleOption.Default).AsType<Single>(),
7474
Min = Convert.ToSingle(singleOption.Min),
7575
Max = Convert.ToSingle(singleOption.Max),
7676
LogBase = singleOption.LogBase,

test/Microsoft.ML.SearchSpace.Tests/ApprovalTests/SearchSpaceTest.Trainer_default_search_space_test.Microsoft.ML.Trainers.AveragedPerceptronTrainer+Options.approved.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"LearningRate": {
33
"type": "float",
44
"default": 1,
5-
"min": 0.0001,
5+
"min": 0.00010,
66
"max": 1,
77
"log_base": true
88
},

test/Microsoft.ML.SearchSpace.Tests/ApprovalTests/SearchSpaceTest.Trainer_default_search_space_test.Microsoft.ML.Trainers.LbfgsLogisticRegressionBinaryTrainer+Options.approved.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
},
1616
"OptimizationTolerance": {
1717
"type": "float",
18-
"default": 0.0001,
19-
"min": 1E-07,
18+
"default": 0.00010,
19+
"min": 0.0000001,
2020
"max": 0.1,
2121
"log_base": true
2222
},

test/Microsoft.ML.SearchSpace.Tests/ApprovalTests/SearchSpaceTest.Trainer_default_search_space_test.Microsoft.ML.Trainers.LbfgsMaximumEntropyMulticlassTrainer+Options.approved.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
},
1616
"OptimizationTolerance": {
1717
"type": "float",
18-
"default": 0.0001,
19-
"min": 1E-07,
18+
"default": 0.00010,
19+
"min": 0.0000001,
2020
"max": 0.1,
2121
"log_base": true
2222
},

test/Microsoft.ML.SearchSpace.Tests/ApprovalTests/SearchSpaceTest.Trainer_default_search_space_test.Microsoft.ML.Trainers.LbfgsPoissonRegressionTrainer+Options.approved.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
},
1616
"OptimizationTolerance": {
1717
"type": "float",
18-
"default": 0.0001,
19-
"min": 1E-07,
18+
"default": 0.00010,
19+
"min": 0.0000001,
2020
"max": 0.1,
2121
"log_base": true
2222
},

test/Microsoft.ML.SearchSpace.Tests/ApprovalTests/SearchSpaceTest.Trainer_default_search_space_test.Microsoft.ML.Trainers.LdSvmTrainer+Options.approved.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@
88
},
99
"LambdaW": {
1010
"type": "float",
11-
"default": 0.0001,
12-
"min": 0.0001,
11+
"default": 0.00010,
12+
"min": 0.00010,
1313
"max": 1,
1414
"log_base": true
1515
},
1616
"LambdaTheta": {
1717
"type": "float",
18-
"default": 0.0001,
19-
"min": 0.0001,
18+
"default": 0.00010,
19+
"min": 0.00010,
2020
"max": 1,
2121
"log_base": true
2222
},
2323
"LambdaThetaprime": {
2424
"type": "float",
25-
"default": 0.0001,
26-
"min": 0.0001,
25+
"default": 0.00010,
26+
"min": 0.00010,
2727
"max": 1,
2828
"log_base": true
2929
},
3030
"Sigma": {
3131
"type": "float",
32-
"default": 0.0001,
33-
"min": 0.0001,
32+
"default": 0.00010,
33+
"min": 0.00010,
3434
"max": 1,
3535
"log_base": true
3636
},

test/Microsoft.ML.SearchSpace.Tests/ApprovalTests/SearchSpaceTest.Trainer_default_search_space_test.Microsoft.ML.Trainers.LinearSvmTrainer+Options.approved.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"Lambda": {
33
"type": "float",
4-
"default": 0.0001,
5-
"min": 1E-06,
4+
"default": 0.00010,
5+
"min": 0.0000010,
66
"max": 1,
77
"log_base": true
88
},

test/Microsoft.ML.SearchSpace.Tests/ApprovalTests/SearchSpaceTest.Trainer_default_search_space_test.Microsoft.ML.Trainers.OnlineGradientDescentTrainer+Options.approved.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"LearningRate": {
33
"type": "float",
44
"default": 1,
5-
"min": 0.0001,
5+
"min": 0.00010,
66
"max": 1,
77
"log_base": true
88
},

test/Microsoft.ML.SearchSpace.Tests/ApprovalTests/SearchSpaceTest.Trainer_default_search_space_test.Microsoft.ML.Trainers.SdcaLogisticRegressionBinaryTrainer+Options.approved.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
22
"L2Regularization": {
33
"type": "float",
4-
"default": 1E-07,
5-
"min": 1E-07,
4+
"default": 0.0000001,
5+
"min": 0.0000001,
66
"max": 32768,
77
"log_base": true
88
},
99
"L1Regularization": {
1010
"type": "float",
11-
"default": 1E-07,
12-
"min": 1E-07,
11+
"default": 0.0000001,
12+
"min": 0.0000001,
1313
"max": 32768,
1414
"log_base": true
1515
},
1616
"ConvergenceTolerance": {
1717
"type": "float",
18-
"default": 1E-07,
19-
"min": 1E-07,
18+
"default": 0.0000001,
19+
"min": 0.0000001,
2020
"max": 1,
2121
"log_base": true
2222
},
@@ -29,8 +29,8 @@
2929
},
3030
"BiasLearningRate": {
3131
"type": "float",
32-
"default": 1E-07,
33-
"min": 1E-07,
32+
"default": 0.0000001,
33+
"min": 0.0000001,
3434
"max": 1,
3535
"log_base": true
3636
}

test/Microsoft.ML.SearchSpace.Tests/ApprovalTests/SearchSpaceTest.Trainer_default_search_space_test.Microsoft.ML.Trainers.SdcaMaximumEntropyMulticlassTrainer+Options.approved.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
22
"L2Regularization": {
33
"type": "float",
4-
"default": 1E-07,
5-
"min": 1E-07,
4+
"default": 0.0000001,
5+
"min": 0.0000001,
66
"max": 32768,
77
"log_base": true
88
},
99
"L1Regularization": {
1010
"type": "float",
11-
"default": 1E-07,
12-
"min": 1E-07,
11+
"default": 0.0000001,
12+
"min": 0.0000001,
1313
"max": 32768,
1414
"log_base": true
1515
},
1616
"ConvergenceTolerance": {
1717
"type": "float",
18-
"default": 1E-07,
19-
"min": 1E-07,
18+
"default": 0.0000001,
19+
"min": 0.0000001,
2020
"max": 1,
2121
"log_base": true
2222
},
@@ -29,8 +29,8 @@
2929
},
3030
"BiasLearningRate": {
3131
"type": "float",
32-
"default": 1E-07,
33-
"min": 1E-07,
32+
"default": 0.0000001,
33+
"min": 0.0000001,
3434
"max": 1,
3535
"log_base": true
3636
}

test/Microsoft.ML.SearchSpace.Tests/ApprovalTests/SearchSpaceTest.Trainer_default_search_space_test.Microsoft.ML.Trainers.SdcaNonCalibratedBinaryTrainer+Options.approved.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
22
"L2Regularization": {
33
"type": "float",
4-
"default": 1E-07,
5-
"min": 1E-07,
4+
"default": 0.0000001,
5+
"min": 0.0000001,
66
"max": 32768,
77
"log_base": true
88
},
99
"L1Regularization": {
1010
"type": "float",
11-
"default": 1E-07,
12-
"min": 1E-07,
11+
"default": 0.0000001,
12+
"min": 0.0000001,
1313
"max": 32768,
1414
"log_base": true
1515
},
1616
"ConvergenceTolerance": {
1717
"type": "float",
18-
"default": 1E-07,
19-
"min": 1E-07,
18+
"default": 0.0000001,
19+
"min": 0.0000001,
2020
"max": 1,
2121
"log_base": true
2222
},
@@ -29,8 +29,8 @@
2929
},
3030
"BiasLearningRate": {
3131
"type": "float",
32-
"default": 1E-07,
33-
"min": 1E-07,
32+
"default": 0.0000001,
33+
"min": 0.0000001,
3434
"max": 1,
3535
"log_base": true
3636
}

test/Microsoft.ML.SearchSpace.Tests/ApprovalTests/SearchSpaceTest.Trainer_default_search_space_test.Microsoft.ML.Trainers.SdcaNonCalibratedMulticlassTrainer+Options.approved.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
22
"L2Regularization": {
33
"type": "float",
4-
"default": 1E-07,
5-
"min": 1E-07,
4+
"default": 0.0000001,
5+
"min": 0.0000001,
66
"max": 32768,
77
"log_base": true
88
},
99
"L1Regularization": {
1010
"type": "float",
11-
"default": 1E-07,
12-
"min": 1E-07,
11+
"default": 0.0000001,
12+
"min": 0.0000001,
1313
"max": 32768,
1414
"log_base": true
1515
},
1616
"ConvergenceTolerance": {
1717
"type": "float",
18-
"default": 1E-07,
19-
"min": 1E-07,
18+
"default": 0.0000001,
19+
"min": 0.0000001,
2020
"max": 1,
2121
"log_base": true
2222
},
@@ -29,8 +29,8 @@
2929
},
3030
"BiasLearningRate": {
3131
"type": "float",
32-
"default": 1E-07,
33-
"min": 1E-07,
32+
"default": 0.0000001,
33+
"min": 0.0000001,
3434
"max": 1,
3535
"log_base": true
3636
}

test/Microsoft.ML.SearchSpace.Tests/ApprovalTests/SearchSpaceTest.Trainer_default_search_space_test.Microsoft.ML.Trainers.SdcaRegressionTrainer+Options.approved.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
22
"L2Regularization": {
33
"type": "float",
4-
"default": 1E-07,
5-
"min": 1E-07,
4+
"default": 0.0000001,
5+
"min": 0.0000001,
66
"max": 32768,
77
"log_base": true
88
},
99
"L1Regularization": {
1010
"type": "float",
11-
"default": 1E-07,
12-
"min": 1E-07,
11+
"default": 0.0000001,
12+
"min": 0.0000001,
1313
"max": 32768,
1414
"log_base": true
1515
},
1616
"ConvergenceTolerance": {
1717
"type": "float",
18-
"default": 1E-07,
19-
"min": 1E-07,
18+
"default": 0.0000001,
19+
"min": 0.0000001,
2020
"max": 1,
2121
"log_base": true
2222
},
@@ -29,8 +29,8 @@
2929
},
3030
"BiasLearningRate": {
3131
"type": "float",
32-
"default": 1E-07,
33-
"min": 1E-07,
32+
"default": 0.0000001,
33+
"min": 0.0000001,
3434
"max": 1,
3535
"log_base": true
3636
}

test/Microsoft.ML.SearchSpace.Tests/ApprovalTests/SearchSpaceTest.Trainer_default_search_space_test.Microsoft.ML.Trainers.SgdCalibratedTrainer+Options.approved.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"ConvergenceTolerance": {
1010
"type": "double",
1111
"default": 0.1,
12-
"min": 1E-06,
12+
"min": 0.000001,
1313
"max": 0.1,
1414
"log_base": true
1515
},

test/Microsoft.ML.SearchSpace.Tests/ApprovalTests/SearchSpaceTest.Trainer_default_search_space_test.Microsoft.ML.Trainers.SgdNonCalibratedTrainer+Options.approved.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"ConvergenceTolerance": {
1010
"type": "double",
1111
"default": 0.1,
12-
"min": 1E-06,
12+
"min": 0.000001,
1313
"max": 0.1,
1414
"log_base": true
1515
},

test/Microsoft.ML.SearchSpace.Tests/SearchSpaceTest.cs

+26
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6+
using System.Buffers.Text;
7+
using System.Buffers;
68
using System.Text.Json;
79
using System.Text.Json.Serialization;
810
using ApprovalTests;
@@ -29,6 +31,8 @@ public class SearchSpaceTest : TestBase
2931
public SearchSpaceTest(ITestOutputHelper output)
3032
: base(output)
3133
{
34+
_settings.Converters.Add(new DoubleConverter());
35+
_settings.Converters.Add(new SingleConverter());
3236
}
3337

3438
[Fact]
@@ -357,5 +361,27 @@ private class NestSearchSpace
357361
[Range(-1000.0f, 1000, init: 0)]
358362
public float UniformFloat { get; set; }
359363
}
364+
365+
class DoubleConverter : JsonConverter<double>
366+
{
367+
public override double Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
368+
=> Convert.ToDouble(reader.GetDecimal());
369+
370+
public override void Write(Utf8JsonWriter writer, double value, JsonSerializerOptions options)
371+
{
372+
writer.WriteNumberValue(Math.Round(Convert.ToDecimal(value), 6));
373+
}
374+
}
375+
376+
class SingleConverter : JsonConverter<float>
377+
{
378+
public override float Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
379+
=> Convert.ToSingle(reader.GetDecimal());
380+
381+
public override void Write(Utf8JsonWriter writer, float value, JsonSerializerOptions options)
382+
{
383+
writer.WriteNumberValue(Convert.ToDecimal(value));
384+
}
385+
}
360386
}
361387
}

0 commit comments

Comments
 (0)