-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix #6949 #6951
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
Merged
Merged
fix #6949 #6951
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/Microsoft.ML.Core/SearchSpace/BoolearnChoiceAttribute.cs
This file contains hidden or 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,33 @@ | ||
// 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 System; | ||
|
||
namespace Microsoft.ML.SearchSpace; | ||
|
||
/// <summary> | ||
/// Boolean choice attribute | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = false, AllowMultiple = false)] | ||
public sealed class BooleanChoiceAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Create a <see cref="BooleanChoiceAttribute"/>. | ||
/// </summary> | ||
public BooleanChoiceAttribute() | ||
{ | ||
DefaultValue = true; | ||
} | ||
|
||
/// <summary> | ||
/// Create a <see cref="BooleanChoiceAttribute"/> with default value. | ||
/// </summary> | ||
/// <param name="defaultValue">default value for this option.</param> | ||
public BooleanChoiceAttribute(bool defaultValue) | ||
{ | ||
DefaultValue = defaultValue; | ||
} | ||
|
||
public bool DefaultValue { get; } | ||
} |
This file contains hidden or 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,50 @@ | ||
// 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 System; | ||
using System.Diagnostics.Contracts; | ||
using System.Linq; | ||
|
||
namespace Microsoft.ML.SearchSpace; | ||
|
||
/// <summary> | ||
/// Choice attribute | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = false, AllowMultiple = false)] | ||
public sealed class ChoiceAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Create a <see cref="ChoiceAttribute"/> with <paramref name="candidates"/>. | ||
/// </summary> | ||
public ChoiceAttribute(params object[] candidates) | ||
{ | ||
var candidatesType = candidates.Select(o => o.GetType()).Distinct(); | ||
Contract.Assert(candidatesType.Count() == 1, "multiple candidates type detected"); | ||
this.Candidates = candidates; | ||
this.DefaultValue = null; | ||
} | ||
|
||
/// <summary> | ||
/// Create a <see cref="ChoiceAttribute"/> with <paramref name="candidates"/> and <paramref name="defaultValue"/>. | ||
/// </summary> | ||
public ChoiceAttribute(object[] candidates, object defaultValue) | ||
{ | ||
var candidatesType = candidates.Select(o => o.GetType()).Distinct(); | ||
Contract.Assert(candidatesType.Count() == 1, "multiple candidates type detected"); | ||
Contract.Assert(candidatesType.First() == defaultValue.GetType(), "candidates type doesn't match with defaultValue type"); | ||
|
||
this.Candidates = candidates; | ||
this.DefaultValue = defaultValue; | ||
} | ||
|
||
/// <summary> | ||
/// Get the candidates of this option. | ||
/// </summary> | ||
public object[] Candidates { get; } | ||
|
||
/// <summary> | ||
/// Get the default value of this option. | ||
/// </summary> | ||
public object DefaultValue { get; } | ||
} |
This file contains hidden or 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,21 @@ | ||
// 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 System; | ||
|
||
namespace Microsoft.ML.SearchSpace; | ||
|
||
/// <summary> | ||
/// attribution class for nest option. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = false, AllowMultiple = false)] | ||
public sealed class NestOptionAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Create an <see cref="NestOptionAttribute"/>. | ||
/// </summary> | ||
public NestOptionAttribute() | ||
{ | ||
} | ||
} |
This file contains hidden or 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,88 @@ | ||
// 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 System; | ||
|
||
namespace Microsoft.ML.SearchSpace; | ||
|
||
/// <summary> | ||
/// Range attribute | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = false, AllowMultiple = false)] | ||
public sealed class RangeAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Create a <see cref="RangeAttribute"/> | ||
/// </summary> | ||
public RangeAttribute(double min, double max, bool logBase = false) | ||
{ | ||
this.Min = min; | ||
this.Max = max; | ||
this.Init = null; | ||
this.LogBase = logBase; | ||
} | ||
|
||
/// <summary> | ||
/// Create a <see cref="RangeAttribute"/> | ||
/// </summary> | ||
public RangeAttribute(double min, double max, double init, bool logBase = false) | ||
{ | ||
this.Min = min; | ||
this.Max = max; | ||
this.Init = init; | ||
this.LogBase = logBase; | ||
} | ||
|
||
/// <summary> | ||
/// Create a <see cref="RangeAttribute"/> | ||
/// </summary> | ||
public RangeAttribute(int min, int max, bool logBase = false) | ||
{ | ||
this.Min = min; | ||
this.Max = max; | ||
this.Init = null; | ||
this.LogBase = logBase; | ||
} | ||
|
||
/// <summary> | ||
/// Create a <see cref="RangeAttribute"/> | ||
/// </summary> | ||
public RangeAttribute(int min, int max, int init, bool logBase = false) | ||
{ | ||
this.Min = min; | ||
this.Max = max; | ||
this.Init = init; | ||
this.LogBase = logBase; | ||
} | ||
|
||
/// <summary> | ||
/// Create a <see cref="RangeAttribute"/> | ||
/// </summary> | ||
public RangeAttribute(float min, float max, bool logBase = false) | ||
{ | ||
this.Min = min; | ||
this.Max = max; | ||
this.Init = null; | ||
this.LogBase = logBase; | ||
} | ||
|
||
/// <summary> | ||
/// Create a <see cref="RangeAttribute"/> | ||
/// </summary> | ||
public RangeAttribute(float min, float max, float init, bool logBase = false) | ||
{ | ||
this.Min = min; | ||
this.Max = max; | ||
this.Init = init; | ||
this.LogBase = logBase; | ||
} | ||
|
||
public object Min { get; } | ||
|
||
public object Max { get; } | ||
|
||
public object Init { get; } | ||
|
||
public bool LogBase { get; } | ||
} |
37 changes: 0 additions & 37 deletions
37
src/Microsoft.ML.SearchSpace/Attribute/BooleanChoiceAttribute.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
src/Microsoft.ML.SearchSpace/Attribute/NestOptionAttribute.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.