コード例 #1
0
def test_linear_param_recording():
    name = "myname"
    group = "mygroup"
    distributions = DummyDistributions()
    distributions.Linear("myname", 1, 10, 10, group='mygroup')
    hp_config = distributions.get_hyperparameters_config()
    check_params(hp_config, distributions, name, group, 'Linear', 10, 1, 10)
コード例 #2
0
def test_choice_param_recording():
    name = "myname"
    group = "mygroup"
    distributions = DummyDistributions()
    distributions.Choice("myname", ['a', 'b', 'c'], group='mygroup')
    hp_config = distributions.get_hyperparameters_config()
    check_params(hp_config, distributions, name, group, 'Choice', 3, 'a', 'c')
コード例 #3
0
def test_range_param_recording():
    name = "myname"
    group = "mygroup"
    distributions = DummyDistributions()
    distributions.Range("myname", 1, 10, 2, group='mygroup')
    hp_config = distributions.get_hyperparameters_config()
    check_params(hp_config, distributions, name, group, 'Range', 5, 1, 10)
コード例 #4
0
def test_fixed_param_recording():
    name = "myname"
    group = "mygroup"
    distributions = DummyDistributions()
    distributions.Fixed("myname", 42, group='mygroup')
    hp_config = distributions.get_hyperparameters_config()
    check_params(hp_config, distributions, name, group, 'Fixed', 1, 42, 42)
コード例 #5
0
def test_boolean_param_recording():
    name = "myname"
    group = "mygroup"
    distributions = DummyDistributions()
    distributions.Boolean("myname", group='mygroup')
    hp_config = distributions.get_hyperparameters_config()
    check_params(hp_config, distributions, name, group, 'Boolean', 2, True,
                 False)
コード例 #6
0
def dd():
    distributions = DummyDistributions()
    distributions.Boolean("myname", group='mygroup')
    distributions.Range('range', 1, 20)
    distributions.Linear('linear', 1, 20, 10)
    distributions.Logarithmic('log', 1, 20, 10)
    return distributions
コード例 #7
0
ファイル: functions.py プロジェクト: zhangzhaolei/keras-tuner
def reset_distributions():
    """Reset the _DISTRIBUTIONS global object to the default."""
    config._DISTRIBUTIONS = DummyDistributions()
コード例 #8
0
ファイル: functions.py プロジェクト: zhangzhaolei/keras-tuner
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from kerastuner.distributions import DummyDistributions
from kerastuner import config

# set dummydistribution as default to allows evaluation and analysis
config._DISTRIBUTIONS = DummyDistributions()


def reset_distributions():
    """Reset the _DISTRIBUTIONS global object to the default."""
    config._DISTRIBUTIONS = DummyDistributions()


def Fixed(name, value, group="default"):
    """Return a fixed selected value
    Args:
        name (str): name of the parameter
        value: value of the parameter
        group (str): Optional logical grouping of the parameters
    Returns:
        value
コード例 #9
0
def test_logarithmic_correctness():
    res = DummyDistributions().Logarithmic('test', 1, 2, 10)
    assert res == 1
コード例 #10
0
def range_range_correctness():
    range_type_correctness_test(DummyDistributions())
コード例 #11
0
def test_linear_correctness():
    linear_correctness_test(DummyDistributions())
コード例 #12
0
def choice_range_correctness():
    choice_correctness_test(DummyDistributions())
コード例 #13
0
def test_bool_correctness():
    bool_correctness_test(DummyDistributions())
コード例 #14
0
def test_fixed_correctness():
    fixed_correctness_test(DummyDistributions())
コード例 #15
0
def test_duplicate_param_name_same_group():
    distributions = DummyDistributions()
    distributions.Boolean("test", group='a')
    with pytest.raises(ValueError):
        distributions.Boolean("test", group='a')
コード例 #16
0
def test_duplicate_param_name_diff_group():
    distributions = DummyDistributions()
    distributions.Boolean("test", group='a')
    distributions.Boolean("test", group='b')
    hp_config = distributions.get_hyperparameters_config()
    assert len(hp_config) == 2