text
stringlengths
81
112k
The recommended way of using Monitor is opening it with the `with` statement. In this case the user doesn't need to call this function explicitly. Otherwise, the function should be called before starting the optimiser. The function evaluates the global_step variable in order to get its initial ...
The recommended way of using Monitor is opening it with the `with` statement. In this case the user doesn't need to call this function explicitly. Otherwise the function should be called when the optimisation is done. The function sets the optimisation completed flag in the monitoring context a...
Prints the tasks' timing summary. def print_summary(self) -> None: """ Prints the tasks' timing summary. """ print("Tasks execution time summary:") for mon_task in self._monitor_tasks: print("%s:\t%.4f (sec)" % (mon_task.task_name, mon_task.total_time))
Called at each iteration. This function does time measurements, updates timing in the monitoring context and calls all monitoring tasks. def _on_iteration(self, *args, **kwargs) -> None: """ Called at each iteration. This function does time measurements, updates timing in the ...
Returns an iterator that constructs a sequence of trigger levels with growing intervals. The interval is growing exponentially until it reaches the maximum value. Then the interval stays the same and the sequence becomes linear. An optional starting level `start_level` defaults to the initial i...
Attempts to lock the location used by this writer. Will raise an error if the location is already locked by another writer. Will do nothing if the location is already locked by this writer. def __lock_location(self) -> None: """ Attempts to lock the location used by this writer. Will ra...
Releases the lock on the location used by this writer. Will do nothing if the lock is already released. def __release_location(self) -> None: """ Releases the lock on the location used by this writer. Will do nothing if the lock is already released. """ if self._is_activ...
Sets the flag indicating that the event file should be flushed at each call. def with_flush_immediately(self, flush_immediately: Optional[bool]=True)\ -> 'BaseTensorBoardTask': """ Sets the flag indicating that the event file should be flushed at each call. """ self._flush_i...
Evaluates the summary tensor and writes the result to the event file. :param context: Monitor context :param feed_dict: Input values dictionary to be provided to the `session.run` when evaluating the summary tensor. def _eval_summary(self, context: MonitorContext, feed_dict: Optional[Dict]=None...
Returns two n-by-n matrices. The first one contains all the x values and the second all the y values of a cartesian product between `xx` and `yy`. def make_grid(xx, yy): """ Returns two n-by-n matrices. The first one contains all the x values and the second all the y values of a cartesian product bet...
Elapsed time [µs] between start and stop timestamps. If stop is empty then returned time is difference between start and current timestamp. def elapsed(self): """ Elapsed time [µs] between start and stop timestamps. If stop is empty then returned time is difference between start and cur...
Gives an access to action's watcher. :return: Action's watcher instance. def watcher(self) -> Watcher: """ Gives an access to action's watcher. :return: Action's watcher instance. """ if not hasattr(self, "_watcher"): self._watcher = Watcher() ...
Set start, stop and step loop configuration. :param stop: Looop stop iteration integer. If None then loop becomes infinite. :param start: Loop iteration start integer. :param step: Loop iteration interval integer. :return: Loop itself. def with_settings(...
Run performs loop iterations. :param context: Action context. def run(self, context: ActionContext): """ Run performs loop iterations. :param context: Action context. """ iterator = itertools.count(start=self.start, step=self.step) for i in iterator: ...
Replace optimizer tensor. :param model: Tensorflow tensor. :return: Optimization instance self reference. def with_optimizer_tensor(self, tensor: Union[tf.Tensor, tf.Operation]) -> 'Optimization': """ Replace optimizer tensor. :param model: Tensorflow tensor. ...
Replace Tensorflow session run kwargs. Check Tensorflow session run [documentation](https://www.tensorflow.org/api_docs/python/tf/Session). :param kwargs: Dictionary of tensors as keys and numpy arrays or primitive python types as values. :return: Optimization instance s...
The `optimizer_tensor` is an attribute for getting optimization's optimizer tensor. def optimizer_tensor(self) -> Union[tf.Tensor, tf.Operation]: """ The `optimizer_tensor` is an attribute for getting optimization's optimizer tensor. """ return _get_attr(self, _optimizer...
Single-output GP conditional. The covariance matrices used to calculate the conditional have the following shape: - Kuu: M x M - Kuf: M x N - Kff: N or N x N Further reference ----------------- - See `gpflow.conditionals._conditional` (below) for a detailed explanation of conditional...
Given f, representing the GP at the points X, produce the mean and (co-)variance of the GP at the points Xnew. Additionally, there may be Gaussian uncertainty about f as represented by q_sqrt. In this case `f` represents the mean of the distribution and q_sqrt the square-root of the covariance. Ad...
`sample_conditional` will return a sample from the conditional distribution. In most cases this means calculating the conditional mean m and variance v and then returning m + sqrt(v) * eps, with eps ~ N(0, 1). However, for some combinations of Mok and Mof more efficient sampling routines exists. The dis...
r""" Given a g1 and g2, and distribution p and q such that p(g2) = N(g2;0,Kmm) p(g1) = N(g1;0,Knn) p(g1|g2) = N(g1;0,Knm) And q(g2) = N(g2;f,q_sqrt*q_sqrt^T) This method computes the mean and (co)variance of q(g1) = \int q(g2) p(g1|g2) :param Kmn: M x [...] x N :param K...
Calculates the conditional for uncertain inputs Xnew, p(Xnew) = N(Xnew_mu, Xnew_var). See ``conditional`` documentation for further reference. :param Xnew_mu: mean of the inputs, size N x Din :param Xnew_var: covariance matrix of the inputs, size N x Din x Din :param feat: gpflow.InducingFeature object...
Returns a sample from a D-dimensional Multivariate Normal distribution :param mean: [..., N, D] :param cov: [..., N, D] or [..., N, D, D] :param cov_structure: "diag" or "full" - "diag": cov holds the diagonal elements of the covariance matrix - "full": cov holds the full covariance matrix (without ...
Reshapes fvar to the correct shape, specified by `full_cov` and `full_output_cov`. :param fvar: has shape N x P (full_cov = False) or P x N x N (full_cov = True). :return: 1. full_cov: True and full_output_cov: True fvar N x P x N x P 2. full_cov: True and full_output_cov: False fvar P x ...
Roll the tensor `A` forward `num_rolls` times def _rollaxis_right(A, num_rolls): """ Roll the tensor `A` forward `num_rolls` times """ assert num_rolls > 0 rank = tf.rank(A) perm = tf.concat([rank - num_rolls + tf.range(num_rolls), tf.range(rank - num_rolls)], 0) return tf.transpose(A, perm)
Models which used to take only Z can now pass `feat` and `Z` to this method. This method will check for consistency and return the correct feature. This allows backwards compatibility in for the methods. def inducingpoint_wrapper(feat, Z): """ Models which used to take only Z can now pass `feat` and `Z...
Custom version of _square_dist that allows sc to provide per-datapoint length scales. sc: N x M x D. def _cust_square_dist(A, B, sc): """ Custom version of _square_dist that allows sc to provide per-datapoint length scales. sc: N x M x D. """ return tf.reduce_sum(tf.squa...
Construct a tensorflow function to compute the bound on the marginal likelihood. For a derivation of the terms in here, see the associated SGPR notebook. def _build_likelihood(self): """ Construct a tensorflow function to compute the bound on the marginal likelihood. For a deriv...
Compute the mean and variance of the latent function at some new points Xnew. For a derivation of the terms in here, see the associated SGPR notebook. def _build_predict(self, Xnew, full_cov=False): """ Compute the mean and variance of the latent function at some new points Xnew...
Computes the mean and variance of q(u), the variational distribution on inducing outputs. SVGP with this q(u) should predict identically to SGPR. :return: mu, A def compute_qu(self): """ Computes the mean and variance of q(u), the variational distribution on inducing out...
Construct a tensorflow function to compute the bound on the marginal likelihood. def _build_likelihood(self): """ Construct a tensorflow function to compute the bound on the marginal likelihood. """ # FITC approximation to the log marginal likelihood is # log ( ...
Compute the mean and variance of the latent function at some new points Xnew. def _build_predict(self, Xnew, full_cov=False): """ Compute the mean and variance of the latent function at some new points Xnew. """ _, _, Luu, L, _, _, gamma = self._build_common_terms() ...
Transposes tensors with leading dimensions. Leading dimensions in permutation list represented via ellipsis `...`. When leading dimensions are found, `transpose` method considers them as a single grouped element indexed by 0 in `perm` list. So, passing `perm=[-2, ..., -1]`, you assume that your input t...
Work out what a sensible type for the array is. if the default type is float32, downcast 64bit float to float32. For ints, assume int32 def normalize_num_type(num_type): """ Work out what a sensible type for the array is. if the default type is float32, downcast 64bit float to float32. For ints, assume...
Takes a D x M tensor `vectors' and maps it to a D x matrix_size X matrix_sizetensor where the where the lower triangle of each matrix_size x matrix_size matrix is constructed by unpacking each M-vector. Native TensorFlow version of Custom Op by Mark van der Wilk. def int_shape(x): return list(...
Converts between GPflow indexing and tensorflow indexing `method` is a function that broadcasts over the first dimension (i.e. like all tensorflow matrix ops): `method` inputs DN1, DNN `method` outputs DN1, DNN :return: Function that broadcasts over the final dimension (i.e. compatible with GPfl...
Take inverse of lower triangular (e.g. Cholesky) matrix. This function broadcasts over the first index. :param M: Tensor with lower triangular structure of shape DxNxN :return: The inverse of the Cholesky decomposition. Same shape as input. def _inverse_lower_triangular(M): """ Take inverse of low...
Make Tensorflow optimization tensor. This method builds natural gradients optimization tensor and initializes all necessary variables created by the optimizer. :param model: GPflow model. :param session: Tensorflow session. :param var_list: List of tuples of variatio...
Forward-mode pushforward analogous to the pullback defined by tf.gradients. With tf.gradients, grad_ys is the vector being pulled back, and here d_xs is the vector being pushed forward, i.e. this computes (∂ys / ∂xs)^T ∂xs. This is adapted from https://github.com/HIPS/autograd/pull/175#issuecom...
Implements equation 10 from @inproceedings{salimbeni18, title={Natural Gradients in Practice: Non-Conjugate Variational Inference in Gaussian Process Models}, author={Salimbeni, Hugh and Eleftheriadis, Stefanos and Hensman, James}, booktitle={AISTATS}, year={201...
:param model: GPflow model with objective tensor. :param session: Session where optimization will be run. :param var_list: List of extra variables which should be trained during optimization. :param feed_dict: Feed dictionary of tensors passed to session run method. :param maxiter: Numbe...
Store compilation flag at specified index in context's shared data. def _check_index_in_compilations(context: BaseContext, index: str): """Store compilation flag at specified index in context's shared data.""" compilations = 'compilations' if compilations not in context.shared_data: return False ...
Build structured numpy array. :param int type_name: StructType enum converted to integer. :param data: encoded data as a numpy array or a structured numpy array. :param data_dtype: numpy dtype. :param shape: in case when a list of numpy arrays is passed the length (shape) of ...
Takes snapshot of the object and replaces _parent property value on None to avoid infitinite recursion in GPflow tree traversing. :param item: GPflow node object. :return: dictionary snapshot of the node object. def _take_values(self, item: Node) -> DictBasicType: """Takes snapshot of ...
Uses super()._take_values() method, but replaces content of the cached value to the value assossiated with context's session. :param item: GPflow parameter. :return: dictionary snapshot of the parameter object. def _take_values(self, item: Parameter) -> DictBasicType: """Uses super()._...
Return either this GPflow objects requires compilation at decoding time. :param item: GPflow parameter. :return: None or True value. def _take_extras(self, item: Parameter) -> Optional[bool]: """Return either this GPflow objects requires compilation at decoding time. :param item: GPfl...
Uses super()._take_values() method and removes autoflow cache in-place. :param item: GPflow parameterized object. :return: dictionary snapshot of the parameter object. def _take_values(self, item: Parameterized) -> DictBasicType: """Uses super()._take_values() method and removes autoflow cache...
List of default supported coders. First coder in the list has higher priority. def coders(self): """List of default supported coders. First coder in the list has higher priority.""" return (PrimitiveTypeCoder, TensorFlowCoder, FunctionCoder, ListCoder, ...
Path name is a recursive representation parent path name plus the name which was assigned to this object by its parent. In other words, it is stack of parent name where top is always parent's original name: `parent.pathname + parent.childname` and stop condition is root's name. ...
Scans full list of node descendants. :return: Generator of nodes. def _descendants(self): """ Scans full list of node descendants. :return: Generator of nodes. """ children = self._children if children is not None: for child in children.values(): ...
Set child. :param name: Child name. :param child: Parentable object. def _set_child(self, name, child): """ Set child. :param name: Child name. :param child: Parentable object. """ if not isinstance(child, Parentable): raise ValueError('Pare...
Untie child from parent. :param name: Child name. :param child: Parentable object. def _unset_child(self, name, child): """ Untie child from parent. :param name: Child name. :param child: Parentable object. """ if name not in self._children or self._chi...
Set parent. :param parent: Parentable object. :raises ValueError: Self-reference object passed. :raises ValueError: Non-Parentable object passed. def _set_parent(self, parent=None): """ Set parent. :param parent: Parentable object. :raises ValueError: Self-refe...
Produce samples from the posterior latent function(s) at the points Xnew. def predict_f_samples(self, Xnew, num_samples): """ Produce samples from the posterior latent function(s) at the points Xnew. """ mu, var = self._build_predict(Xnew, full_cov=True) # N x P, # P x ...
Compute the mean and variance of held-out data at the points Xnew def predict_y(self, Xnew): """ Compute the mean and variance of held-out data at the points Xnew """ pred_f_mean, pred_f_var = self._build_predict(Xnew) return self.likelihood.predict_mean_and_var(pred_f_mean, pre...
Compute the (log) density of the data Ynew at the points Xnew Note that this computes the log density of the data individually, ignoring correlations between them. The result is a matrix the same shape as Ynew containing the log densities. def predict_density(self, Xnew, Ynew): """ ...
r""" Construct a tensorflow function to compute the likelihood. \log p(Y | theta). def _build_likelihood(self): r""" Construct a tensorflow function to compute the likelihood. \log p(Y | theta). """ K = self.kern.K(self.X) + tf.eye(tf.shape(self.X)[0],...
Xnew is a data matrix, the points at which we want to predict. This method computes p(F* | Y) where F* are points on the GP at Xnew, Y are noisy observations at X. def _build_predict(self, Xnew, full_cov=False): """ Xnew is a data matrix, the points at which we want to pr...
Compute the expectation <obj1(x) obj2(x)>_p(x) Uses Gauss-Hermite quadrature for approximate integration. :type p: (mu, cov) tuple or a `ProbabilityDistribution` object :type obj1: kernel, mean function, (kernel, features), or None :type obj2: kernel, mean function, (kernel, features), or None :par...
Return the function of interest (kernel or mean) for the expectation depending on the type of :obj: and whether any features are given def get_eval_func(obj, feature, slice=np.s_[...]): """ Return the function of interest (kernel or mean) for the expectation depending on the type of :obj: and whether a...
General handling of quadrature expectations for Gaussians and DiagonalGaussians Fallback method for missing analytic expectations def _quadrature_expectation(p, obj1, feature1, obj2, feature2, num_gauss_hermite_points): """ General handling of quadrature expectations for Gaussians and DiagonalGaussians ...
Handling of quadrature expectations for Markov Gaussians (useful for time series) Fallback method for missing analytic expectations wrt Markov Gaussians Nota Bene: obj1 is always associated with x_n, whereas obj2 always with x_{n+1} if one requires e.g. <x_{n+1} K_{x_n, Z}>_p(x_{n:n+1}), compute ...
Compute the expectation <obj1(x) obj2(x)>_p(x) Uses multiple-dispatch to select an analytical implementation, if one is available. If not, it falls back to quadrature. :type p: (mu, cov) tuple or a `ProbabilityDistribution` object :type obj1: kernel, mean function, (kernel, features), or None :type...
Compute the expectation: <diag(K_{X, X})>_p(X) - K_{.,.} :: RBF kernel :return: N def _expectation(p, kern, none1, none2, none3, nghp=None): """ Compute the expectation: <diag(K_{X, X})>_p(X) - K_{.,.} :: RBF kernel :return: N """ return kern.Kdiag(p.mu)
Compute the expectation: <K_{X, Z}>_p(X) - K_{.,.} :: RBF kernel :return: NxM def _expectation(p, kern, feat, none1, none2, nghp=None): """ Compute the expectation: <K_{X, Z}>_p(X) - K_{.,.} :: RBF kernel :return: NxM """ with params_as_tensors_for(kern, feat): ...
Compute the expectation: expectation[n] = <x_n K_{x_n, Z}>_p(x_n) - K_{.,.} :: RBF kernel :return: NxDxM def _expectation(p, mean, none, kern, feat, nghp=None): """ Compute the expectation: expectation[n] = <x_n K_{x_n, Z}>_p(x_n) - K_{.,.} :: RBF kernel :return: NxDxM """...
Compute the expectation: expectation[n] = <Ka_{Z1, x_n} Kb_{x_n, Z2}>_p(x_n) - Ka_{.,.}, Kb_{.,.} :: RBF kernels Ka and Kb as well as Z1 and Z2 can differ from each other. :return: N x dim(Z1) x dim(Z2) def _expectation(p, kern1, feat1, kern2, feat2, nghp=None): """ Compute the expectation...
Compute the expectation: <diag(K_{X, X})>_p(X) - K_{.,.} :: Linear kernel :return: N def _expectation(p, kern, none1, none2, none3, nghp=None): """ Compute the expectation: <diag(K_{X, X})>_p(X) - K_{.,.} :: Linear kernel :return: N """ with params_as_tensors_for(kern)...
Compute the expectation: <K_{X, Z}>_p(X) - K_{.,.} :: Linear kernel :return: NxM def _expectation(p, kern, feat, none1, none2, nghp=None): """ Compute the expectation: <K_{X, Z}>_p(X) - K_{.,.} :: Linear kernel :return: NxM """ with params_as_tensors_for(kern, feat): ...
Compute the expectation: expectation[n] = <K_{Z, x_n} x_{n+1}^T>_p(x_{n:n+1}) - K_{.,.} :: Linear kernel - p :: MarkovGaussian distribution (p.cov 2x(N+1)xDxD) :return: NxMxD def _expectation(p, kern, feat, mean, none, nghp=None): """ Compute the expectation: expectation[n] =...
Compute the expectation: expectation[n] = <Ka_{Z1, x_n} Kb_{x_n, Z2}>_p(x_n) - Ka_{.,.}, Kb_{.,.} :: Linear kernels Ka and Kb as well as Z1 and Z2 can differ from each other, but this is supported only if the Gaussian p is Diagonal (p.cov NxD) and Ka, Kb have disjoint active_dims in which case t...
Compute the expectation: expectation[n] = <x_n K_{x_n, Z}>_p(x_n) - K_{.,} :: Linear kernel or the equivalent for MarkovGaussian :return: NxDxM def _expectation(p, mean, none, kern, feat, nghp=None): """ Compute the expectation: expectation[n] = <x_n K_{x_n, Z}>_p(x_n) - K_{.,}...
Compute the expectation: expectation[n] = <m(x_n)^T K_{x_n, Z}>_p(x_n) - m(x_i) = c :: Constant function - K_{.,.} :: Kernel function :return: NxQxM def _expectation(p, constant_mean, none, kern, feat, nghp=None): """ Compute the expectation: expectation[n] = <m(x_n)^T K_{x_n, Z...
Compute the expectation: expectation[n] = <m(x_n)^T K_{x_n, Z}>_p(x_n) - m(x_i) = A x_i + b :: Linear mean function - K_{.,.} :: Kernel function :return: NxQxM def _expectation(p, linear_mean, none, kern, feat, nghp=None): """ Compute the expectation: expectation[n] = <m...
Compute the expectation: <m(X)>_p(X) - m(x) :: Linear, Identity or Constant mean function :return: NxQ def _expectation(p, mean, none1, none2, none3, nghp=None): """ Compute the expectation: <m(X)>_p(X) - m(x) :: Linear, Identity or Constant mean function :return: NxQ """ ...
Compute the expectation: expectation[n] = <m1(x_n)^T m2(x_n)>_p(x_n) - m1(.), m2(.) :: Constant mean functions :return: NxQ1xQ2 def _expectation(p, mean1, none1, mean2, none2, nghp=None): """ Compute the expectation: expectation[n] = <m1(x_n)^T m2(x_n)>_p(x_n) - m1(.), m2(.) :: Con...
Compute the expectation: expectation[n] = <m1(x_n)^T m2(x_n)>_p(x_n) - m1(.) :: Identity mean function - m2(.) :: Linear mean function :return: NxDxQ def _expectation(p, mean1, none1, mean2, none2, nghp=None): """ Compute the expectation: expectation[n] = <m1(x_n)^T m2(x_n)>_p(x_n)...
Compute the expectation: expectation[n] = <m1(x_n)^T m2(x_n)>_p(x_n) - m1(.) :: Linear mean function - m2(.) :: Identity mean function :return: NxQxD def _expectation(p, mean1, none1, mean2, none2, nghp=None): """ Compute the expectation: expectation[n] = <m1(x_n)^T m2(x_n)>_p(x_n)...
Compute the expectation: expectation[n] = <m1(x_n)^T m2(x_n)>_p(x_n) - m1(.), m2(.) :: Linear mean functions :return: NxQ1xQ2 def _expectation(p, mean1, none1, mean2, none2, nghp=None): """ Compute the expectation: expectation[n] = <m1(x_n)^T m2(x_n)>_p(x_n) - m1(.), m2(.) :: Linea...
r""" Compute the expectation: <\Sum_i Ki_{X, Z}>_p(X) - \Sum_i Ki_{.,.} :: Sum kernel :return: NxM def _expectation(p, kern, feat, none2, none3, nghp=None): r""" Compute the expectation: <\Sum_i Ki_{X, Z}>_p(X) - \Sum_i Ki_{.,.} :: Sum kernel :return: NxM """ retur...
r""" Compute the expectation: expectation[n] = <m(x_n)^T (\Sum_i Ki_{x_n, Z})>_p(x_n) - \Sum_i Ki_{.,.} :: Sum kernel :return: NxQxM def _expectation(p, mean, none, kern, feat, nghp=None): r""" Compute the expectation: expectation[n] = <m(x_n)^T (\Sum_i Ki_{x_n, Z})>_p(x_n) - \...
r""" Compute the expectation: expectation[n] = <(\Sum_i K1_i_{Z1, x_n}) (\Sum_j K2_j_{x_n, Z2})>_p(x_n) - \Sum_i K1_i_{.,.}, \Sum_j K2_j_{.,.} :: Sum kernels :return: NxM1xM2 def _expectation(p, kern1, feat1, kern2, feat2, nghp=None): r""" Compute the expectation: expectation[n] = <(\S...
Compute the expectation: expectation[n] = <Ka_{Z1, x_n} Kb_{x_n, Z2}>_p(x_n) - K_lin_{.,.} :: RBF kernel - K_rbf_{.,.} :: Linear kernel Different Z1 and Z2 are handled if p is diagonal and K_lin and K_rbf have disjoint active_dims, in which case the joint expectations simplify into a product...
Compute the expectation: expectation[n] = <Ka_{Z1, x_n} Kb_{x_n, Z2}>_p(x_n) - K_lin_{.,.} :: Linear kernel - K_rbf_{.,.} :: RBF kernel Different Z1 and Z2 are handled if p is diagonal and K_lin and K_rbf have disjoint active_dims, in which case the joint expectations simplify into a product...
r""" Compute the expectation: <\HadamardProd_i diag(Ki_{X[:, active_dims_i], X[:, active_dims_i]})>_p(X) - \HadamardProd_i Ki_{.,.} :: Product kernel - p :: DiagonalGaussian distribution (p.cov NxD) :return: N def _expectation(p, kern, none1, none2, none3, nghp=None)...
r""" Compute the expectation: expectation[n] = < prodK_{Z, x_n} prodK_{x_n, Z} >_p(x_n) = < (\HadamardProd_i Ki_{Z[:, active_dims_i], x[n, active_dims_i]}) <-- Mx1 1xM --> (\HadamardProd_j Kj_{x[n, active_dims_j], Z[:, active_dims_j]}) >_p(x_n) (MxM) - \HadamardProd...
Nota Bene: if only one object is passed, obj1 is associated with x_n, whereas obj2 with x_{n+1} def _expectation(p, obj1, feat1, obj2, feat2, nghp=None): """ Nota Bene: if only one object is passed, obj1 is associated with x_n, whereas obj2 with x_{n+1} """ if obj2 is None: gaussian = ...
A straight-forward HMC implementation. The mass matrix is assumed to be the identity. The gpflow model must implement `build_objective` method to build `f` function (tensor) which in turn based on model's internal trainable parameters `x`. f(x) = E(x) we then generate samp...
r""" Given a Normal distribution for the latent function, return the mean of Y if q(f) = N(Fmu, Fvar) and this object represents p(y|f) then this method computes the predictive mean \int\int y p(y|f)q(f) df dy and the predictive va...
r""" Given a Normal distribution for the latent function, and a datum Y, compute the log predictive density of Y. i.e. if q(f) = N(Fmu, Fvar) and this object represents p(y|f) then this method computes the predictive density \log \int p(y=...
r""" Compute the expected log density of the data, given a Gaussian distribution for the function values. if q(f) = N(Fmu, Fvar) and this object represents p(y|f) then this method computes \int (\log p(y|f)) q(f) df. Here, we impl...
args is a list of tensors, to be passed to self.likelihoods.<func_name> args[-1] is the 'Y' argument, which contains the indexes to self.likelihoods. This function splits up the args using dynamic_partition, calls the relevant function on the likelihoods, and re-combines the result. def _part...
A helper function for making predictions. Constructs a probability matrix where each row output the probability of the corresponding label, and the rows match the entries of F. Note that a matrix of F values is flattened. def _make_phi(self, F): """ A helper function for making...
r""" Given a Normal distribution for the latent function, return the mean of Y if q(f) = N(Fmu, Fvar) and this object represents p(y|f) then this method computes the predictive mean \int\int y p(y|f)q(f) df dy and the predictive va...
r""" Given a Normal distribution for the latent function, and a datum Y, compute the log predictive density of Y. i.e. if q(f) = N(Fmu, Fvar) and this object represents p(y|f) then this method computes the predictive density \log \int p(y=...
r""" Compute the expected log density of the data, given a Gaussian distribution for the function values. if q(f) = N(Fmu, Fvar) - Fmu: N x D Fvar: N x D and this object represents p(y|f) - Y: N x 1 then this method computes \int (\log p...
Absorbs a Z^t gate into a W(a) flip. [Where W(a) is shorthand for PhasedX(phase_exponent=a).] Uses the following identity: ───W(a)───Z^t─── ≡ ───W(a)───────────Z^t/2──────────Z^t/2─── (split Z) ≡ ───W(a)───W(a)───Z^-t/2───W(a)───Z^t/2─── (flip Z) ≡ ───W(a)───W(a)──────────W(a+t...
Grabs or cancels a held W gate against an existing W gate. [Where W(a) is shorthand for PhasedX(phase_exponent=a).] Uses the following identity: ───W(a)───W(b)─── ≡ ───Z^-a───X───Z^a───Z^-b───X───Z^b─── ≡ ───Z^-a───Z^-a───Z^b───X───X───Z^b─── ≡ ───Z^-a───Z^-a───Z^b───Z^b─── ...
Cross the held W over a partial W gate. [Where W(a) is shorthand for PhasedX(phase_exponent=a).] Uses the following identity: ───W(a)───W(b)^t─── ≡ ───Z^-a───X───Z^a───W(b)^t────── (expand W(a)) ≡ ───Z^-a───X───W(b-a)^t───Z^a──── (move Z^a across, phasing axis) ≡ ───Z^-a───W(a-...
Crosses exactly one W flip over a partial CZ. [Where W(a) is shorthand for PhasedX(phase_exponent=a).] Uses the following identity: ──────────@───── │ ───W(a)───@^t─── ≡ ───@──────O──────@──────────────────── | | │ (split...