Beispiel #1
0
    def __init__(self,
                 input_dim,
                 num_partials,
                 lengthscales=None,
                 variances=None,
                 frequencies=None):
        gpflow.kernels.Kern.__init__(self, input_dim, active_dims=None)
        len_l = []
        var_l = []
        freq_l = []
        self.ARD = False
        self.num_partials = num_partials

        if lengthscales.all() == None:
            lengthscales = 1. * np.ones((num_partials, 1))
            variances = 0.125 * np.ones((num_partials, 1))
            frequencies = 1. * (1. + np.arange(num_partials))

        for i in range(self.num_partials):
            len_l.append(Param(lengthscales[i], transforms.Logistic(0., 2.)))
            var_l.append(Param(variances[i], transforms.Logistic(0., 1.)))
            freq_l.append(Param(frequencies[i], transforms.positive))

        self.lengthscales = ParamList(len_l)
        self.variance = ParamList(var_l)
        self.frequency = ParamList(freq_l)
Beispiel #2
0
    def __init__(self,
                 input_dim,
                 numc,
                 lengthscales=None,
                 variances=None,
                 frequencies=None):
        gpflow.kernels.Kern.__init__(self, input_dim, active_dims=None)
        self.ARD = False
        self.numc = numc

        if lengthscales == None:
            lengthscales = 1.
            variances = 0.125 * np.ones((numc, 1))
            frequencies = 1. * np.arange(1, numc + 1)

        self.lengthscales = Param(lengthscales, transforms.Logistic(0., 10.))
        for i in range(
                self.numc
        ):  # generate a param object for each  var, and freq, they must be (numc,) arrays.
            setattr(self, 'variance_' + str(i + 1),
                    Param(variances[i], transforms.Logistic(0., 0.25)))
            setattr(self, 'frequency_' + str(i + 1),
                    Param(frequencies[i], transforms.positive))

        for i in range(self.numc):
            exec('self.variance_' + str(i + 1) + '.fixed = ' + str(True))
Beispiel #3
0
    def __init__(self,
                 input_dim,
                 energy=np.asarray([1.]),
                 frequency=np.asarray([2 * np.pi]),
                 variance=1.0,
                 features_as_params=False):
        """
        - input_dim is the dimension of the input to the kernel
        - variance is the (initial) value for the variance parameter(s)
          if ARD=True, there is one variance per input
        - active_dims is a list of length input_dim which controls
          which columns of X are used.
        """
        gpflow.kernels.Kern.__init__(self, input_dim, active_dims=None)
        self.num_features = len(frequency)
        self.variance = Param(variance, transforms.Logistic(0., 0.25))

        if features_as_params:
            energy_list = []
            frequency_list = []
            for i in range(energy.size):
                energy_list.append(Param(energy[i], transforms.positive))
                frequency_list.append(Param(frequency[i], transforms.positive))

            self.energy = ParamList(energy_list)
            self.frequency = ParamList(frequency_list)
        else:
            self.energy = energy
            self.frequency = frequency
Beispiel #4
0
 def __init__(self, input_dim, variance=1., lengthscales=1., gamma=1.):
     gpflow.kernels.Stationary.__init__(self,
                                        input_dim=input_dim,
                                        variance=variance,
                                        lengthscales=lengthscales)
     self.gamma = Param(gamma, transforms.Logistic(0.00001, 2.))