Transform parameters into exp-scale weights.
195856
def exp_transform(params):
    """"""
    weights = np.exp(np.asarray(params) - np.mean(params))
    return (len(weights) / weights.sum()) * weights
80567
def normalize_pts(pts, ymax, scaler=2):
    
    return [(x * scaler, ymax - (y * scaler)) for x, y in pts]
1314128
def to_parameter_specs(self, name_prefix=""):
    """"""
    specs = []
    for name, categories, _ in self._categorical_params.values():
      spec = {
          "parameterName": name_prefix + name,
          "type": "CATEGORICAL",
          "categoricalValues": categories,
      }
      specs.append(spec)

    for name, feasible_points, scale, _ in self._discrete_params.values():
      spec = {
          "parameterName": name_prefix + name,
          "type": "DISCRETE",
          "discreteValues": feasible_points,
      }
      if scale:
        spec["scaleType"] = self.SCALES_STR[scale]
      specs.append(spec)

    for name, min_val, max_val, scale, _ in self._float_params.values():
      spec = {
          "parameterName": name_prefix + name,
          "type": "DOUBLE",
          "minValue": min_val,
          "maxValue": max_val,
      }
      if scale:
        spec["scaleType"] = self.SCALES_STR[scale]
      specs.append(spec)

    for name, min_val, max_val, scale, _ in self._int_params.values():
      spec = {
          "parameterName": name_prefix + name,
          "type": "INTEGER",
          "minValue": min_val,
          "maxValue": max_val,
      }
      if scale:
        spec["scaleType"] = self.SCALES_STR[scale]
      specs.append(spec)

    return specs
751629
def _process_generic_param(pval, def_unit, equivalencies=[]):
        """"""
        if isinstance(pval, u.Quantity):
            outval = pval.to(def_unit, equivalencies).value
        else:  # Assume already in desired unit
            outval = pval
        return outval
378216
def get_means_and_scales(self):
        
        return self.optim.parameters[::2], np.exp(self.optim.parameters[1::2])
85865
def fromvars(cls, dataset, batch_size, train=None, **kwargs):
        """"""
        batch = cls()
        batch.batch_size = batch_size
        batch.dataset = dataset
        batch.fields = dataset.fields.keys()
        for k, v in kwargs.items():
            setattr(batch, k, v)
        return batch
927740
def _get_xy_scaling_parameters(self):
        """"""
        return self.mx, self.bx, self.my, self.by
844464
def map_parameters(cls, params):
        """"""

        d = {}
        for k, v in six.iteritems(params):
            d[cls.FIELD_MAP.get(k.lower(), k)] = v
        return d
636092
def get_parameters(scale, f=5, input_parameters=None):
    """"""
    p = default_parameters.copy()
    if input_parameters is not None:
        # if parameters are passed in, overwrite the default values
        p.update(input_parameters)
    parameters = {}
    # running quark masses and alpha_s
    parameters['m_b'] = m_b(p['m_b'], scale, f, p['alpha_s'])
    parameters['m_c'] = m_c(p['m_c'], scale, f, p['alpha_s'])
    parameters['m_s'] = m_s(p['m_s'], scale, f, p['alpha_s'])
    parameters['m_u'] = m_s(p['m_u'], scale, f, p['alpha_s'])
    parameters['m_d'] = m_s(p['m_d'], scale, f, p['alpha_s'])
    parameters['alpha_s'] = alpha_s(scale, f, p['alpha_s'])
    # no running is performed for these parameters
    for k in ['m_W', 'm_Z', 'GF',
              'alpha_e',
              'Vus', 'Vub', 'Vcb', 'delta',
              'm_e', 'm_mu', 'm_tau', ]:
        parameters[k] = p[k]
    return parameters
321938
def scale_to_vol(self, vol):
        """"""

        f = np.exp((np.log(vol) - np.log(self.vol)) / self.n)  # linear factor
        self.expand *= f
        self.cov *= f**2
        self.am *= f**-2
        self.axlens *= f
        self.axes *= f
        self.vol = vol
9520
def weights(self):
        """"""
        m = self.kernel.feature_log_prob_[self._match_class_pos()]
        u = self.kernel.feature_log_prob_[self._nonmatch_class_pos()]

        return self._prob_inverse_transform(numpy.exp(m - u))
71759
def _set_params(self, x):
        """"""
        assert x.size == self.num_params
        self.varianceU = x[0]
        self.varianceY = x[1]
        self.lengthscaleU = x[2]
        self.lengthscaleY = x[3]
415724
def _as_rescale(self, get, targetbitdepth):
        """"""

        width,height,pixels,meta = get()
        maxval = 2**meta['bitdepth'] - 1
        targetmaxval = 2**targetbitdepth - 1
        factor = float(targetmaxval) / float(maxval)
        meta['bitdepth'] = targetbitdepth
        def iterscale():
            for row in pixels:
                yield map(lambda x: int(round(x*factor)), row)
        if maxval == targetmaxval:
            return width, height, pixels, meta
        else:
            return width, height, iterscale(), meta
1263493
def weight_variable(shape):
    """"""
    initial = tf.truncated_normal(shape, stddev=0.1)
    return tf.Variable(initial)
654905
def _af_inv_scaled(x):
    """"""
    x = _transform_to_2d(x)

    cov_matrix = np.atleast_2d(np.cov(x, rowvar=False))

    cov_matrix_power = _mat_sqrt_inv(cov_matrix)

    return x.dot(cov_matrix_power)
201922
def _get_params(self):
        """"""
        return np.hstack((self.varianceU,self.varianceY, self.lengthscaleU,self.lengthscaleY))
931498
def _normalize_number_values(self, parameters):
        """"""
        for key, value in parameters.items():
            if isinstance(value, (int, float)):
                parameters[key] = str(Decimal(value).normalize(self._context))