forked from dotnet/machinelearning
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return distinct array of ParameterSet when ProposeSweep is called (do…
…tnet#368) * Changed List to HashSet to ensure that there are no duplicates
- Loading branch information
1 parent
89953cd
commit c4a03af
Showing
5 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
test/Microsoft.ML.Sweeper.Tests/Microsoft.ML.Sweeper.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
<DefineConstants>CORECLR</DefineConstants> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Microsoft.ML.Sweeper\Microsoft.ML.Sweeper.csproj" /> | ||
<ProjectReference Include="..\Microsoft.ML.TestFramework\Microsoft.ML.TestFramework.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Microsoft.ML.Runtime; | ||
using Microsoft.ML.Runtime.CommandLine; | ||
using Microsoft.ML.Runtime.Data; | ||
using Microsoft.ML.Runtime.RunTests; | ||
using Microsoft.ML.Runtime.Sweeper; | ||
using System; | ||
using System.IO; | ||
using Xunit; | ||
|
||
namespace Microsoft.ML.Sweeper.Tests | ||
{ | ||
public class SweeperTest | ||
{ | ||
[Fact] | ||
public void UniformRandomSweeperReturnsDistinctValuesWhenProposeSweep() | ||
{ | ||
DiscreteValueGenerator valueGenerator = CreateDiscreteValueGenerator(); | ||
|
||
using (var writer = new StreamWriter(new MemoryStream())) | ||
using (var env = new TlcEnvironment(42, outWriter: writer, errWriter: writer)) | ||
{ | ||
var sweeper = new UniformRandomSweeper(env, | ||
new SweeperBase.ArgumentsBase(), | ||
new[] { valueGenerator }); | ||
|
||
var results = sweeper.ProposeSweeps(3); | ||
Assert.NotNull(results); | ||
|
||
int length = results.Length; | ||
Assert.Equal(2, length); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void RandomGridSweeperReturnsDistinctValuesWhenProposeSweep() | ||
{ | ||
DiscreteValueGenerator valueGenerator = CreateDiscreteValueGenerator(); | ||
|
||
using (var writer = new StreamWriter(new MemoryStream())) | ||
using (var env = new TlcEnvironment(42, outWriter: writer, errWriter: writer)) | ||
{ | ||
var sweeper = new RandomGridSweeper(env, | ||
new RandomGridSweeper.Arguments(), | ||
new[] { valueGenerator }); | ||
|
||
var results = sweeper.ProposeSweeps(3); | ||
Assert.NotNull(results); | ||
|
||
int length = results.Length; | ||
Assert.Equal(2, length); | ||
} | ||
} | ||
|
||
private static DiscreteValueGenerator CreateDiscreteValueGenerator() | ||
{ | ||
var args = new DiscreteParamArguments() | ||
{ | ||
Name = "TestParam", | ||
Values = new string[] { "one", "two" } | ||
}; | ||
|
||
return new DiscreteValueGenerator(args); | ||
} | ||
} | ||
} |