-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Return distinct array of ParameterSet when ProposeSweep is called #368
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
is this leftover? |
||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Microsoft.ML.Sweeper\Microsoft.ML.Sweeper.csproj" /> | ||
<ProjectReference Include="..\Microsoft.ML.TestFramework\Microsoft.ML.TestFramework.csproj" /> | ||
</ItemGroup> | ||
</Project> |
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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You will see our other files tend to have a standard header: // 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. It may be a nice idea to include that as well in this file. #Closed |
||
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); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the other sweeping algos that we have. They might need the same fix. Will update the comment. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. If you'd like to extend the fix to the other sweepers, take a look at the same method in the other algorithms (inside the Algorithms) ex. ProposeSweeps, in KdoSweeper.
Besides that method, there are other instance fields that cache the results, that might benefit from changing their type from a List to a HashSet.
In reply to: 196221925 [](ancestors = 196221925)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sweeper in KdoSweeper eventually uses SweeperBase which this PR already fixes. Yes, there are some other fixes to make, but probably better as another issue. I could look at them in a few days under a different issue #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressing them on a different PR, and logging something as a reminder sounds good to me.
AFA ProposeSweep in Kdo, the do while loop as a potential for creating duplicates, since they all are generated indipendantly, there is no duplication check on the cached results etc. But again, adressing it as a separate issue sounds good.
In reply to: 196239510 [](ancestors = 196239510)