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_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_fully_connected(rng): """Sample a fully connected problem.""" n_layer = rng.choice([2, 3, 4, 5]) fixed = utils.sample_bool(rng, 0.5) cfg = { "n_features": utils.sample_log_int(rng, 1, 16), "n_classes": 2, "activation": utils.sample_activation(rng), "bs": utils.sample_log_int(rng, 1, 200), "n_samples": utils.sample_log_int(rng, 1, 30), } if fixed: cfg["hidden_sizes"] = [utils.sample_log_int(rng, 4, 32)] * n_layer else: cfg["hidden_sizes"] = [ utils.sample_log_int(rng, 4, 32) for _ in range(n_layer) ] return cfg
def sample_conv_pooling_family_cfg(seed): """Sample a task config for a conv net with pooling model on image datasets. 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 = {} layer_choices = [1, 2, 3, 4, 5] max_layer = np.max(layer_choices) n_layers = rng.choice(layer_choices) # pattern for how strides are chosen. Either all 2s, repeated 1,2 # or repeated 2,1. stride_pattern = rng.choice(["all_two", "one_two", "two_one"]) if stride_pattern == "all_two": cfg["strides"] = ([2] * max_layer)[0:n_layers] elif stride_pattern == "one_two": cfg["strides"] = ([1, 2] * max_layer)[0:n_layers] elif stride_pattern == "two_one": cfg["strides"] = ([2, 1] * max_layer)[0:n_layers] cfg["strides"] = list(zip(cfg["strides"], cfg["strides"])) cfg["hidden_units"] = [ utils.sample_log_int(rng, 8, 64) for _ in range(n_layers) ] cfg["activation"] = utils.sample_activation(rng) cfg["w_init"] = utils.sample_initializer(rng) cfg["padding"] = [ str(rng.choice([snt.SAME, snt.VALID])) for _ in range(n_layers) ] cfg["pool_type"] = str(rng.choice(["mean", "max", "squared_mean"])) cfg["use_bias"] = bool(rng.choice([True, False])) cfg["dataset"] = utils.sample_image_dataset(rng) cfg["center_data"] = bool(rng.choice([True, False])) return cfg
def _sample_norm(rng): """Sample a norm problem.""" return { "dim": utils.sample_log_int(rng, 3, 1000), "norm_power": rng.uniform(0.1, 5.0), }