def _sample_bowl_problems(rng): """Sample a bowl problem.""" is_noise = utils.sample_bool(rng, 0.5) return { "cond": utils.sample_log_float(rng, 0.01, 100), "angle": rng.choice([0, 0, np.pi / 4., np.pi / 3]), "noise_stdev": utils.sample_log_float(rng, 0.01, 10.0) if is_noise else 0.0, }
def sample_quadratic_family_cfg(seed): """Sample a task config for a toy quadratic based problem. See QuadraticBasedTask for more information. These configs are nested python structures that provide enough information to create an instance of the problem. Args: seed: int Random seed to generate task from. Returns: A nested dictionary containing a configuration. """ rng = np.random.RandomState(seed) cfg = {} cfg["A_dist"] = _sample_distribution_over_matrix(rng) cfg["initial_dist"] = _sample_vector_dist(rng) cfg["output_fn"] = rng.choice(["identity", "log"]) cfg["dims"] = utils.sample_log_int(rng, 2, 3000) cfg["seed"] = rng.randint(0, 100000) cfg["loss_scale"] = utils.sample_log_float(rng, 1e-5, 1e3) if rng.choice([True, False]): cfg["noise"] = {} cfg["noise"]["A_noise"] = _sample_matrix_noise_dist(rng) else: cfg["noise"] = None return cfg
def _sample_min_max_well(rng): """Sample a min max well problem.""" is_noise = utils.sample_bool(rng, 0.5) return { "dim": utils.sample_log_int(rng, 10, 1000), "noise_stdev": utils.sample_log_float(rng, 0.01, 10.0) if is_noise else 0.0, }
def _sample_optimization_test_problems(rng): """Sample an optimization test function problem.""" is_noise = utils.sample_bool(rng, 0.5) return { "problem": rng.choice(sorted(_opt_test_problems.keys())), "noise_stdev": utils.sample_log_float(rng, 0.01, 10.0) if is_noise else 0.0, }
def _sample_quadratic_problem(rng): """Sample a quadratic problem.""" is_noise = utils.sample_bool(rng, 0.5) return { "dim": utils.sample_log_int(rng, 10, 1000), "noise_stdev": utils.sample_log_float(rng, 0.01, 10.0) if is_noise else 0.0, }
def _sample_sparse_softmax_regression(rng): """Sample a sparse softmax regression problem.""" is_noise = utils.sample_bool(rng, 0.5) return { "n_features": utils.sample_log_int(rng, 2, 100), "n_classes": 2, "noise_stdev": utils.sample_log_float(rng, 0.01, 10.0) if is_noise else 0.0, "bs": utils.sample_log_int(rng, 1, 50), "n_samples": utils.sample_log_int(rng, 1, 30), }
def _sample_rescale_problem(rng): """Sample a rescale problem. This problem modifies a sampled base problem by rescaling the parameters. Args: rng: Random state Returns: The sampled config. """ base_config = rng.choice(_to_modify) return { "base": (base_config, _problem_sample_get[base_config][0](rng)), "scale": utils.sample_log_float(rng, 0.001, 1000.0), }
def _sample_sparse_problem(rng): """Sample a sparse problem. This problem modifies a sampled base problem by setting some gradients to zero. Args: rng: Random state Returns: The sampled config. """ is_noise = utils.sample_bool(rng, 0.5) base_config = rng.choice(_to_modify) return { "base": (base_config, _problem_sample_get[base_config][0](rng)), "zero_probability": rng.uniform(0.9, 0.99), "noise_stdev": utils.sample_log_float(rng, 0.01, 10.0) if is_noise else 0.0, }