Skip to content

autora.theorist.bsr.prior

get_prior_dict(prior_name='Uniform')

Get the dictionary of prior information as well as several list of key operator properties

Argument

prior_name: the name of the prior dictionary to use

Returns:

Name Type Description
ops_name_lst

the list of operator names

ops_weight_lst

the list of operator weights

prior_dict

the dictionary of operator prior information

Source code in temp_dir/bsr/src/autora/theorist/bsr/prior.py
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
def get_prior_dict(prior_name="Uniform"):
    """
    Get the dictionary of prior information as well as several list of key operator properties

    Argument:
        prior_name: the name of the prior dictionary to use

    Returns:
        ops_name_lst: the list of operator names
        ops_weight_lst: the list of operator weights
        prior_dict: the dictionary of operator prior information
    """
    ops_prior = _get_prior(prior_name)
    ops_init = _get_ops_init()
    ops_fn_and_arity = _get_ops_with_arity()

    ops_name_lst = list(ops_prior.keys())
    ops_weight_lst = list(ops_prior.values())
    prior_dict = {
        k: {
            "init": ops_init.get(k, {}),
            "fn": ops_fn_and_arity[k][0],
            "arity": ops_fn_and_arity[k][1],
            "weight": ops_prior[k],
        }
        for k in ops_prior
    }

    return ops_name_lst, ops_weight_lst, prior_dict

get_prior_list(prior_name='Uniform')

Get a dictionary of key prior properties

Argument

prior_name: the name of the prior dictionary to use

Returns:

Type Description

a dictionary that maps a prior property (e.g. name) to the list of such properties for each operator.

Source code in temp_dir/bsr/src/autora/theorist/bsr/prior.py
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
def get_prior_list(prior_name="Uniform"):
    """
    Get a dictionary of key prior properties

    Argument:
        prior_name: the name of the prior dictionary to use

    Returns:
        a dictionary that maps a prior property (e.g. `name`) to the list of such properties
            for each operator.
    """
    ops_prior = _get_prior(prior_name)
    ops_init = _get_ops_init()
    ops_fn_and_arity = _get_ops_with_arity()

    ops_name_lst = list(ops_prior.keys())
    ops_weight_lst = list(ops_prior.values())
    ops_init_lst = [ops_init.get(k, None) for k in ops_name_lst]
    ops_fn_lst = [ops_fn_and_arity[k][0] for k in ops_name_lst]
    ops_arity_lst = [ops_fn_and_arity[k][1] for k in ops_name_lst]
    return {
        "name": ops_name_lst,
        "weight": ops_weight_lst,
        "init": ops_init_lst,
        "fn": ops_fn_lst,
        "arity": ops_arity_lst,
    }

linear_init(**hyper_params)

Initialization function for the linear operator. Two parameters, slope (a) and intercept (b) are initialized.

Parameters:

Name Type Description Default
hyper_params

the dictionary for hyperparameters. Specifically, this function requires sigma_a and sigma_b to be present.

{}

Returns: a dictionary with initialized a and b parameters.

Source code in temp_dir/bsr/src/autora/theorist/bsr/prior.py
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def linear_init(**hyper_params) -> Dict:
    """
    Initialization function for the linear operator. Two parameters, slope
    (a) and intercept (b) are initialized.

    Arguments:
        hyper_params: the dictionary for hyperparameters. Specifically, this
            function requires `sigma_a` and `sigma_b` to be present.
    Returns:
        a dictionary with initialized `a` and `b` parameters.
    """
    sigma_a, sigma_b = hyper_params.get("sigma_a", 1), hyper_params.get("sigma_b", 1)
    return {
        "a": norm.rvs(loc=1, scale=np.sqrt(sigma_a)),
        "b": norm.rvs(loc=0, scale=np.sqrt(sigma_b)),
    }