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)
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')
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)
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)
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)
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
def reset_distributions(): """Reset the _DISTRIBUTIONS global object to the default.""" config._DISTRIBUTIONS = DummyDistributions()
# 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
def test_logarithmic_correctness(): res = DummyDistributions().Logarithmic('test', 1, 2, 10) assert res == 1
def range_range_correctness(): range_type_correctness_test(DummyDistributions())
def test_linear_correctness(): linear_correctness_test(DummyDistributions())
def choice_range_correctness(): choice_correctness_test(DummyDistributions())
def test_bool_correctness(): bool_correctness_test(DummyDistributions())
def test_fixed_correctness(): fixed_correctness_test(DummyDistributions())
def test_duplicate_param_name_same_group(): distributions = DummyDistributions() distributions.Boolean("test", group='a') with pytest.raises(ValueError): distributions.Boolean("test", group='a')
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