def temporal_kernel(self): kernel = White(variance=self.model_config['noise_inner']) m_inds = list(range(self.m)) # Initialize a non-linear kernels over inputs if self.model_config['input_nonlinear']: scales = [self.model_config['scale'] ] * self.m if self.model_config[ 'scale_tie'] else self.model_config['scale'] if self.model_config['rq']: kernel += RationalQuadratic(active_dims=m_inds, variance=1.0, lengthscales=scales, alpha=1e-2) else: kernel += SquaredExponential(active_dims=m_inds, variance=1.0, lengthscales=scales) # Add a periodic kernel over inputs # Decay????? if self.model_config['per']: scales = [self.model_config['per_scale']] * self.m periods = [self.model_config['per_period']] * self.m base_kernel = SquaredExponential(active_dims=m_inds, variance=1.0, lengthscales=scales) kernel += Periodic(base_kernel, period=periods) # Add a linear kernel over inputs if self.model_config['input_linear']: variances = [self.model_config['input_linear_scale']] * self.m kernel += LinearKernel(active_dims=m_inds, variance=variances) return kernel
def boosting_kernel(self): kernels = [] if self.model_config['nonlinear']: if self.model_config['rq']: kernels.append( RationalQuadratic( variance=1.0, lengthscales=self.model_config['nonlinear_scale'], alpha=1e-2)) else: kernels.append( SquaredExponential( variance=1.0, lengthscales=self.model_config['nonlinear_scale'])) if self.model_config['linear']: kernels.append( LinearKernel(variance=self.model_config['linear_scale'])) kernel = kernels[0] for kerneli in kernels[1:]: kernel += kerneli return kernel
def _kernels_generator(self): def _determine_indicies(m, pi, markov): # Build in the Markov structure: juggle with the indices of the outputs. p_last = pi - 1 # Index of last output that is given as input. p_start = 0 if markov is None else max(p_last - (markov - 1), 0) p_num = p_last - p_start + 1 # Determine the indices corresponding to the outputs and inputs. m_inds = list(range(m)) p_inds = list(range(m + p_start, m + p_last + 1)) return m_inds, p_inds, p_num kernels = [] for pi in range(self.num_outputs): m_inds, p_inds, p_num = _determine_indicies( self.m, pi, self.model_config['markov']) # Construct inner-layers noise kernel kernel = White(variance=self.model_config['noise_inner']) # Initialize a non-linear kernels over inputs #if pi==0: scales = [self.model_config['scale'] ] * self.m if self.model_config[ 'scale_tie'] else self.model_config['scale'] if self.model_config['rq']: kernel += RationalQuadratic(active_dims=m_inds, variance=1.0, lengthscales=scales, alpha=1e-2) else: kernel += SquaredExponential(active_dims=m_inds, variance=1.0, lengthscales=scales) # Add a periodic kernel over inputs # Decay????? if self.model_config['per']: scales = [self.model_config['per_scale']] * self.m periods = [self.model_config['per_period']] * self.m base_kernel = SquaredExponential(active_dims=m_inds, variance=1.0, lengthscales=scales) kernel += Periodic(base_kernel, period=periods) # Add a linear kernel over inputs if self.model_config['input_linear']: variances = [self.model_config['input_linear_scale']] * self.m kernel += LinearKernel(active_dims=m_inds, variance=variances) # Add a linear kernel over outputs if self.model_config['linear'] and pi > 0: variances = [self.model_config['linear_scale']] * p_num kernel += LinearKernel(active_dims=p_inds, variance=variances) # Add a non-linear kernel over outputs if self.model_config['nonlinear'] and pi > 0: if self.model_config['nonlinear_dependent']: active_dims = m_inds.extend(p_inds) scales = [self.model_config['scale']] * self.m scales.extend([self.model_config['nonlinear_scale']] * p_num) else: active_dims = p_inds scales = [self.model_config['nonlinear_scale']] * p_num if self.model_config['rq']: kernel += RationalQuadratic(active_dims=active_dims, variance=1.0, lengthscales=scales, alpha=1e-2) else: kernel += SquaredExponential(active_dims=active_dims, variance=1.0, lengthscales=scales) kernels.append(kernel) return kernels