partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
_rollaxis_right
Roll the tensor `A` forward `num_rolls` times
gpflow/conditionals.py
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)
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)
[ "Roll", "the", "tensor", "A", "forward", "num_rolls", "times" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/conditionals.py#L448-L453
[ "def", "_rollaxis_right", "(", "A", ",", "num_rolls", ")", ":", "assert", "num_rolls", ">", "0", "rank", "=", "tf", ".", "rank", "(", "A", ")", "perm", "=", "tf", ".", "concat", "(", "[", "rank", "-", "num_rolls", "+", "tf", ".", "range", "(", "n...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
inducingpoint_wrapper
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.
gpflow/features.py
def inducingpoint_wrapper(feat, Z): """ 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. """ if feat is not None and Z is not None: r...
def inducingpoint_wrapper(feat, Z): """ 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. """ if feat is not None and Z is not None: r...
[ "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", "ba...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/features.py#L135-L151
[ "def", "inducingpoint_wrapper", "(", "feat", ",", "Z", ")", ":", "if", "feat", "is", "not", "None", "and", "Z", "is", "not", "None", ":", "raise", "ValueError", "(", "\"Cannot pass both an InducingFeature instance and Z values\"", ")", "# pragma: no cover", "elif", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
Multiscale._cust_square_dist
Custom version of _square_dist that allows sc to provide per-datapoint length scales. sc: N x M x D.
gpflow/features.py
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.square((tf.expand_dims(A, 1) - tf.expand_dims(B, 0)) / sc), 2)
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.square((tf.expand_dims(A, 1) - tf.expand_dims(B, 0)) / sc), 2)
[ "Custom", "version", "of", "_square_dist", "that", "allows", "sc", "to", "provide", "per", "-", "datapoint", "length", "scales", ".", "sc", ":", "N", "x", "M", "x", "D", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/features.py#L101-L106
[ "def", "_cust_square_dist", "(", "A", ",", "B", ",", "sc", ")", ":", "return", "tf", ".", "reduce_sum", "(", "tf", ".", "square", "(", "(", "tf", ".", "expand_dims", "(", "A", ",", "1", ")", "-", "tf", ".", "expand_dims", "(", "B", ",", "0", ")...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
SGPR._build_likelihood
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.
gpflow/models/sgpr.py
def _build_likelihood(self): """ 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. """ num_inducing = len(self.feature) num_data = tf.cast(tf.shape(self.Y)[0],...
def _build_likelihood(self): """ 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. """ num_inducing = len(self.feature) num_data = tf.cast(tf.shape(self.Y)[0],...
[ "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", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/sgpr.py#L125-L160
[ "def", "_build_likelihood", "(", "self", ")", ":", "num_inducing", "=", "len", "(", "self", ".", "feature", ")", "num_data", "=", "tf", ".", "cast", "(", "tf", ".", "shape", "(", "self", ".", "Y", ")", "[", "0", "]", ",", "settings", ".", "float_ty...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
SGPR._build_predict
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.
gpflow/models/sgpr.py
def _build_predict(self, Xnew, full_cov=False): """ 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. """ num_inducing = len(self.feature) err = self.Y - self.mea...
def _build_predict(self, Xnew, full_cov=False): """ 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. """ num_inducing = len(self.feature) err = self.Y - self.mea...
[ "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", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/sgpr.py#L163-L192
[ "def", "_build_predict", "(", "self", ",", "Xnew", ",", "full_cov", "=", "False", ")", ":", "num_inducing", "=", "len", "(", "self", ".", "feature", ")", "err", "=", "self", ".", "Y", "-", "self", ".", "mean_function", "(", "self", ".", "X", ")", "...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
SGPR.compute_qu
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
gpflow/models/sgpr.py
def compute_qu(self): """ 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 """ Kuf = features.Kuf(self.feature, self.kern, self.X) Kuu = feature...
def compute_qu(self): """ 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 """ Kuf = features.Kuf(self.feature, self.kern, self.X) Kuu = feature...
[ "Computes", "the", "mean", "and", "variance", "of", "q", "(", "u", ")", "the", "variational", "distribution", "on", "inducing", "outputs", ".", "SVGP", "with", "this", "q", "(", "u", ")", "should", "predict", "identically", "to", "SGPR", ".", ":", "retur...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/sgpr.py#L196-L216
[ "def", "compute_qu", "(", "self", ")", ":", "Kuf", "=", "features", ".", "Kuf", "(", "self", ".", "feature", ",", "self", ".", "kern", ",", "self", ".", "X", ")", "Kuu", "=", "features", ".", "Kuu", "(", "self", ".", "feature", ",", "self", ".", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
GPRFITC._build_likelihood
Construct a tensorflow function to compute the bound on the marginal likelihood.
gpflow/models/sgpr.py
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 ( normal( y | mean, K_fitc ) ) # where K_fitc = Qff + diag( \nu ) # where Qf...
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 ( normal( y | mean, K_fitc ) ) # where K_fitc = Qff + diag( \nu ) # where Qf...
[ "Construct", "a", "tensorflow", "function", "to", "compute", "the", "bound", "on", "the", "marginal", "likelihood", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/sgpr.py#L279-L321
[ "def", "_build_likelihood", "(", "self", ")", ":", "# FITC approximation to the log marginal likelihood is", "# log ( normal( y | mean, K_fitc ) )", "# where K_fitc = Qff + diag( \\nu )", "# where Qff = Kfu Kuu^{-1} Kuf", "# with \\nu_i = Kff_{i,i} - Qff_{i,i} + \\sigma^2", "# We need to compu...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
GPRFITC._build_predict
Compute the mean and variance of the latent function at some new points Xnew.
gpflow/models/sgpr.py
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() Kus = features.Kuf(self.feature, self.kern, Xnew) # size M x Xnew w = tf...
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() Kus = features.Kuf(self.feature, self.kern, Xnew) # size M x Xnew w = tf...
[ "Compute", "the", "mean", "and", "variance", "of", "the", "latent", "function", "at", "some", "new", "points", "Xnew", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/sgpr.py#L324-L347
[ "def", "_build_predict", "(", "self", ",", "Xnew", ",", "full_cov", "=", "False", ")", ":", "_", ",", "_", ",", "Luu", ",", "L", ",", "_", ",", "_", ",", "gamma", "=", "self", ".", "_build_common_terms", "(", ")", "Kus", "=", "features", ".", "Ku...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
leading_transpose
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...
gpflow/misc.py
def leading_transpose(tensor: tf.Tensor, perm: List[Union[int, type(...)]]) -> tf.Tensor: """ 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 e...
def leading_transpose(tensor: tf.Tensor, perm: List[Union[int, type(...)]]) -> tf.Tensor: """ 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 e...
[ "Transposes", "tensors", "with", "leading", "dimensions", ".", "Leading", "dimensions", "in", "permutation", "list", "represented", "via", "ellipsis", "...", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/misc.py#L87-L121
[ "def", "leading_transpose", "(", "tensor", ":", "tf", ".", "Tensor", ",", "perm", ":", "List", "[", "Union", "[", "int", ",", "type", "(", "...", ")", "]", "]", ")", "->", "tf", ".", "Tensor", ":", "perm", "=", "copy", ".", "copy", "(", "perm", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
normalize_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 int32
gpflow/misc.py
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 int32 """ if isinstance(num_type, tf.DType): num_type = num_type.as_numpy_dtype.type if num_type in [np.float32, np.flo...
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 int32 """ if isinstance(num_type, tf.DType): num_type = num_type.as_numpy_dtype.type if num_type in [np.float32, np.flo...
[ "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" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/misc.py#L147-L162
[ "def", "normalize_num_type", "(", "num_type", ")", ":", "if", "isinstance", "(", "num_type", ",", "tf", ".", "DType", ")", ":", "num_type", "=", "num_type", ".", "as_numpy_dtype", ".", "type", "if", "num_type", "in", "[", "np", ".", "float32", ",", "np",...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
vec_to_tri
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(...
gpflow/misc.py
def vec_to_tri(vectors, N): """ 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 vec_to_tri(vectors, N): """ 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. ...
[ "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", "cons...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/misc.py#L174-L196
[ "def", "vec_to_tri", "(", "vectors", ",", "N", ")", ":", "indices", "=", "list", "(", "zip", "(", "*", "np", ".", "tril_indices", "(", "N", ")", ")", ")", "indices", "=", "tf", ".", "constant", "(", "[", "list", "(", "i", ")", "for", "i", "in",...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
swap_dimensions
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...
gpflow/training/natgrad_optimizer.py
def swap_dimensions(method): """ 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 f...
def swap_dimensions(method): """ 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 f...
[ "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...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/natgrad_optimizer.py#L324-L345
[ "def", "swap_dimensions", "(", "method", ")", ":", "@", "functools", ".", "wraps", "(", "method", ")", "def", "wrapper", "(", "a_nd", ",", "b_dnn", ",", "swap", "=", "True", ")", ":", "if", "swap", ":", "if", "a_nd", ".", "get_shape", "(", ")", "."...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_inverse_lower_triangular
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.
gpflow/training/natgrad_optimizer.py
def _inverse_lower_triangular(M): """ 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. """ if M.get...
def _inverse_lower_triangular(M): """ 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. """ if M.get...
[ "Take", "inverse", "of", "lower", "triangular", "(", "e", ".", "g", ".", "Cholesky", ")", "matrix", ".", "This", "function", "broadcasts", "over", "the", "first", "index", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/natgrad_optimizer.py#L386-L398
[ "def", "_inverse_lower_triangular", "(", "M", ")", ":", "if", "M", ".", "get_shape", "(", ")", ".", "ndims", "!=", "3", ":", "# pragma: no cover", "raise", "ValueError", "(", "\"Number of dimensions for input is required to be 3.\"", ")", "D", ",", "N", "=", "tf...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
NatGradOptimizer.make_optimize_tensor
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...
gpflow/training/natgrad_optimizer.py
def make_optimize_tensor(self, model, session=None, var_list=None): """ Make Tensorflow optimization tensor. This method builds natural gradients optimization tensor and initializes all necessary variables created by the optimizer. :param model: GPflow model. :pa...
def make_optimize_tensor(self, model, session=None, var_list=None): """ Make Tensorflow optimization tensor. This method builds natural gradients optimization tensor and initializes all necessary variables created by the optimizer. :param model: GPflow model. :pa...
[ "Make", "Tensorflow", "optimization", "tensor", ".", "This", "method", "builds", "natural", "gradients", "optimization", "tensor", "and", "initializes", "all", "necessary", "variables", "created", "by", "the", "optimizer", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/natgrad_optimizer.py#L89-L103
[ "def", "make_optimize_tensor", "(", "self", ",", "model", ",", "session", "=", "None", ",", "var_list", "=", "None", ")", ":", "session", "=", "model", ".", "enquire_session", "(", "session", ")", "with", "session", ".", "as_default", "(", ")", ",", "tf"...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
NatGradOptimizer._forward_gradients
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...
gpflow/training/natgrad_optimizer.py
def _forward_gradients(ys, xs, d_xs): """ 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 adapt...
def _forward_gradients(ys, xs, d_xs): """ 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 adapt...
[ "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", "vec...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/natgrad_optimizer.py#L144-L163
[ "def", "_forward_gradients", "(", "ys", ",", "xs", ",", "d_xs", ")", ":", "# this should be v = [tf.placeholder(y.dtype) for y in ys], but tensorflow", "# wants a value for the placeholder, even though it never gets used", "v", "=", "[", "tf", ".", "placeholder_with_default", "("...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
NatGradOptimizer._build_natgrad_step_op
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...
gpflow/training/natgrad_optimizer.py
def _build_natgrad_step_op(self, model, q_mu_param, q_sqrt_param, xi_transform): """ Implements equation 10 from @inproceedings{salimbeni18, title={Natural Gradients in Practice: Non-Conjugate Variational Inference in Gaussian Process Models}, author={Salimbeni, Hugh an...
def _build_natgrad_step_op(self, model, q_mu_param, q_sqrt_param, xi_transform): """ Implements equation 10 from @inproceedings{salimbeni18, title={Natural Gradients in Practice: Non-Conjugate Variational Inference in Gaussian Process Models}, author={Salimbeni, Hugh an...
[ "Implements", "equation", "10", "from" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/natgrad_optimizer.py#L174-L238
[ "def", "_build_natgrad_step_op", "(", "self", ",", "model", ",", "q_mu_param", ",", "q_sqrt_param", ",", "xi_transform", ")", ":", "objective", "=", "model", ".", "objective", "q_mu", ",", "q_sqrt", "=", "q_mu_param", ".", "constrained_tensor", ",", "q_sqrt_para...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
Optimizer.minimize
: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...
gpflow/training/optimizer.py
def minimize(self, model, session=None, var_list=None, feed_dict=None, maxiter=1000, initialize=True, anchor=True, step_callback=None, **kwargs): """ :param model: GPflow model with objective tensor. :param session: Session where optimization will be run. :param var_list...
def minimize(self, model, session=None, var_list=None, feed_dict=None, maxiter=1000, initialize=True, anchor=True, step_callback=None, **kwargs): """ :param model: GPflow model with objective tensor. :param session: Session where optimization will be run. :param var_list...
[ ":", "param", "model", ":", "GPflow", "model", "with", "objective", "tensor", ".", ":", "param", "session", ":", "Session", "where", "optimization", "will", "be", "run", ".", ":", "param", "var_list", ":", "List", "of", "extra", "variables", "which", "shou...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/optimizer.py#L39-L57
[ "def", "minimize", "(", "self", ",", "model", ",", "session", "=", "None", ",", "var_list", "=", "None", ",", "feed_dict", "=", "None", ",", "maxiter", "=", "1000", ",", "initialize", "=", "True", ",", "anchor", "=", "True", ",", "step_callback", "=", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_check_index_in_compilations
Store compilation flag at specified index in context's shared data.
gpflow/saver/coders.py
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 return index in context.shared_data[compilations]
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 return index in context.shared_data[compilations]
[ "Store", "compilation", "flag", "at", "specified", "index", "in", "context", "s", "shared", "data", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/saver/coders.py#L643-L648
[ "def", "_check_index_in_compilations", "(", "context", ":", "BaseContext", ",", "index", ":", "str", ")", ":", "compilations", "=", "'compilations'", "if", "compilations", "not", "in", "context", ".", "shared_data", ":", "return", "False", "return", "index", "in...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
StructCoder.struct
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 ...
gpflow/saver/coders.py
def struct(cls, type_name: int, data: np.ndarray, data_dtype: np.dtype = None, shape: Tuple = None): """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: nu...
def struct(cls, type_name: int, data: np.ndarray, data_dtype: np.dtype = None, shape: Tuple = None): """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: nu...
[ "Build", "structured", "numpy", "array", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/saver/coders.py#L182-L204
[ "def", "struct", "(", "cls", ",", "type_name", ":", "int", ",", "data", ":", "np", ".", "ndarray", ",", "data_dtype", ":", "np", ".", "dtype", "=", "None", ",", "shape", ":", "Tuple", "=", "None", ")", ":", "data_dtype", "=", "data", ".", "dtype", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
NodeCoder._take_values
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.
gpflow/saver/coders.py
def _take_values(self, item: Node) -> DictBasicType: """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.""" values ...
def _take_values(self, item: Node) -> DictBasicType: """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.""" values ...
[ "Takes", "snapshot", "of", "the", "object", "and", "replaces", "_parent", "property", "value", "on", "None", "to", "avoid", "infitinite", "recursion", "in", "GPflow", "tree", "traversing", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/saver/coders.py#L479-L488
[ "def", "_take_values", "(", "self", ",", "item", ":", "Node", ")", "->", "DictBasicType", ":", "values", "=", "super", "(", ")", ".", "_take_values", "(", "item", ")", "values", "[", "'_parent'", "]", "=", "None", "return", "values" ]
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
ParameterCoder._take_values
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.
gpflow/saver/coders.py
def _take_values(self, item: Parameter) -> DictBasicType: """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.""" ses...
def _take_values(self, item: Parameter) -> DictBasicType: """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.""" ses...
[ "Uses", "super", "()", ".", "_take_values", "()", "method", "but", "replaces", "content", "of", "the", "cached", "value", "to", "the", "value", "assossiated", "with", "context", "s", "session", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/saver/coders.py#L498-L509
[ "def", "_take_values", "(", "self", ",", "item", ":", "Parameter", ")", "->", "DictBasicType", ":", "session", "=", "self", ".", "context", ".", "session", "values", "=", "super", "(", ")", ".", "_take_values", "(", "item", ")", "cached_value", "=", "np"...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
ParameterCoder._take_extras
Return either this GPflow objects requires compilation at decoding time. :param item: GPflow parameter. :return: None or True value.
gpflow/saver/coders.py
def _take_extras(self, item: Parameter) -> Optional[bool]: """Return either this GPflow objects requires compilation at decoding time. :param item: GPflow parameter. :return: None or True value. """ index = item.tf_compilation_index() if index is not None: i...
def _take_extras(self, item: Parameter) -> Optional[bool]: """Return either this GPflow objects requires compilation at decoding time. :param item: GPflow parameter. :return: None or True value. """ index = item.tf_compilation_index() if index is not None: i...
[ "Return", "either", "this", "GPflow", "objects", "requires", "compilation", "at", "decoding", "time", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/saver/coders.py#L511-L523
[ "def", "_take_extras", "(", "self", ",", "item", ":", "Parameter", ")", "->", "Optional", "[", "bool", "]", ":", "index", "=", "item", ".", "tf_compilation_index", "(", ")", "if", "index", "is", "not", "None", ":", "if", "item", ".", "index", "==", "...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
ParameterizedCoder._take_values
Uses super()._take_values() method and removes autoflow cache in-place. :param item: GPflow parameterized object. :return: dictionary snapshot of the parameter object.
gpflow/saver/coders.py
def _take_values(self, item: Parameterized) -> DictBasicType: """Uses super()._take_values() method and removes autoflow cache in-place. :param item: GPflow parameterized object. :return: dictionary snapshot of the parameter object.""" values = super()._take_values(item) values...
def _take_values(self, item: Parameterized) -> DictBasicType: """Uses super()._take_values() method and removes autoflow cache in-place. :param item: GPflow parameterized object. :return: dictionary snapshot of the parameter object.""" values = super()._take_values(item) values...
[ "Uses", "super", "()", ".", "_take_values", "()", "method", "and", "removes", "autoflow", "cache", "in", "-", "place", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/saver/coders.py#L541-L549
[ "def", "_take_values", "(", "self", ",", "item", ":", "Parameterized", ")", "->", "DictBasicType", ":", "values", "=", "super", "(", ")", ".", "_take_values", "(", "item", ")", "values", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "values", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
CoderDispatcher.coders
List of default supported coders. First coder in the list has higher priority.
gpflow/saver/coders.py
def coders(self): """List of default supported coders. First coder in the list has higher priority.""" return (PrimitiveTypeCoder, TensorFlowCoder, FunctionCoder, ListCoder, DictCoder, SliceCoder, ParameterCo...
def coders(self): """List of default supported coders. First coder in the list has higher priority.""" return (PrimitiveTypeCoder, TensorFlowCoder, FunctionCoder, ListCoder, DictCoder, SliceCoder, ParameterCo...
[ "List", "of", "default", "supported", "coders", ".", "First", "coder", "in", "the", "list", "has", "higher", "priority", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/saver/coders.py#L588-L600
[ "def", "coders", "(", "self", ")", ":", "return", "(", "PrimitiveTypeCoder", ",", "TensorFlowCoder", ",", "FunctionCoder", ",", "ListCoder", ",", "DictCoder", ",", "SliceCoder", ",", "ParameterCoder", ",", "ParamListCoder", ",", "ParameterizedCoder", ",", "Transfo...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
Parentable.pathname
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. ...
gpflow/core/parentable.py
def pathname(self): """ 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 con...
def pathname(self): """ 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 con...
[ "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", ...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/parentable.py#L78-L93
[ "def", "pathname", "(", "self", ")", ":", "if", "self", ".", "parent", "is", "self", ":", "return", "self", ".", "name", "parent", "=", "self", ".", "_parent", "return", "misc", ".", "tensor_name", "(", "parent", ".", "pathname", ",", "parent", ".", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
Parentable._descendants
Scans full list of node descendants. :return: Generator of nodes.
gpflow/core/parentable.py
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(): yield from child._descendants yield child
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(): yield from child._descendants yield child
[ "Scans", "full", "list", "of", "node", "descendants", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/parentable.py#L126-L136
[ "def", "_descendants", "(", "self", ")", ":", "children", "=", "self", ".", "_children", "if", "children", "is", "not", "None", ":", "for", "child", "in", "children", ".", "values", "(", ")", ":", "yield", "from", "child", ".", "_descendants", "yield", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
Parentable._set_child
Set child. :param name: Child name. :param child: Parentable object.
gpflow/core/parentable.py
def _set_child(self, name, child): """ Set child. :param name: Child name. :param child: Parentable object. """ if not isinstance(child, Parentable): raise ValueError('Parentable child object expected, not {child}'.format(child=child)) child._set_pare...
def _set_child(self, name, child): """ Set child. :param name: Child name. :param child: Parentable object. """ if not isinstance(child, Parentable): raise ValueError('Parentable child object expected, not {child}'.format(child=child)) child._set_pare...
[ "Set", "child", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/parentable.py#L154-L164
[ "def", "_set_child", "(", "self", ",", "name", ",", "child", ")", ":", "if", "not", "isinstance", "(", "child", ",", "Parentable", ")", ":", "raise", "ValueError", "(", "'Parentable child object expected, not {child}'", ".", "format", "(", "child", "=", "child...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
Parentable._unset_child
Untie child from parent. :param name: Child name. :param child: Parentable object.
gpflow/core/parentable.py
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._children[name] is not child: msg = 'Child {child} with name "{name}" is not found' ...
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._children[name] is not child: msg = 'Child {child} with name "{name}" is not found' ...
[ "Untie", "child", "from", "parent", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/parentable.py#L166-L177
[ "def", "_unset_child", "(", "self", ",", "name", ",", "child", ")", ":", "if", "name", "not", "in", "self", ".", "_children", "or", "self", ".", "_children", "[", "name", "]", "is", "not", "child", ":", "msg", "=", "'Child {child} with name \"{name}\" is n...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
Parentable._set_parent
Set parent. :param parent: Parentable object. :raises ValueError: Self-reference object passed. :raises ValueError: Non-Parentable object passed.
gpflow/core/parentable.py
def _set_parent(self, parent=None): """ Set parent. :param parent: Parentable object. :raises ValueError: Self-reference object passed. :raises ValueError: Non-Parentable object passed. """ if parent is not None: if not isinstance(parent, Parentable):...
def _set_parent(self, parent=None): """ Set parent. :param parent: Parentable object. :raises ValueError: Self-reference object passed. :raises ValueError: Non-Parentable object passed. """ if parent is not None: if not isinstance(parent, Parentable):...
[ "Set", "parent", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/parentable.py#L180-L193
[ "def", "_set_parent", "(", "self", ",", "parent", "=", "None", ")", ":", "if", "parent", "is", "not", "None", ":", "if", "not", "isinstance", "(", "parent", ",", "Parentable", ")", ":", "raise", "ValueError", "(", "'Parent object must implement Parentable inte...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
GPModel.predict_f_samples
Produce samples from the posterior latent function(s) at the points Xnew.
gpflow/models/model.py
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 N x N jitter = tf.eye(tf.shape(mu)[0], dtype=settings.float_type) * setting...
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 N x N jitter = tf.eye(tf.shape(mu)[0], dtype=settings.float_type) * setting...
[ "Produce", "samples", "from", "the", "posterior", "latent", "function", "(", "s", ")", "at", "the", "points", "Xnew", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/model.py#L185-L198
[ "def", "predict_f_samples", "(", "self", ",", "Xnew", ",", "num_samples", ")", ":", "mu", ",", "var", "=", "self", ".", "_build_predict", "(", "Xnew", ",", "full_cov", "=", "True", ")", "# N x P, # P x N x N", "jitter", "=", "tf", ".", "eye", "(", "tf", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
GPModel.predict_y
Compute the mean and variance of held-out data at the points Xnew
gpflow/models/model.py
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, pred_f_var)
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, pred_f_var)
[ "Compute", "the", "mean", "and", "variance", "of", "held", "-", "out", "data", "at", "the", "points", "Xnew" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/model.py#L201-L206
[ "def", "predict_y", "(", "self", ",", "Xnew", ")", ":", "pred_f_mean", ",", "pred_f_var", "=", "self", ".", "_build_predict", "(", "Xnew", ")", "return", "self", ".", "likelihood", ".", "predict_mean_and_var", "(", "pred_f_mean", ",", "pred_f_var", ")" ]
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
GPModel.predict_density
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.
gpflow/models/model.py
def predict_density(self, Xnew, Ynew): """ 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 densiti...
def predict_density(self, Xnew, Ynew): """ 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 densiti...
[ "Compute", "the", "(", "log", ")", "density", "of", "the", "data", "Ynew", "at", "the", "points", "Xnew" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/model.py#L209-L218
[ "def", "predict_density", "(", "self", ",", "Xnew", ",", "Ynew", ")", ":", "pred_f_mean", ",", "pred_f_var", "=", "self", ".", "_build_predict", "(", "Xnew", ")", "return", "self", ".", "likelihood", ".", "predict_density", "(", "pred_f_mean", ",", "pred_f_v...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
GPR._build_likelihood
r""" Construct a tensorflow function to compute the likelihood. \log p(Y | theta).
gpflow/models/gpr.py
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], dtype=settings.float_type) * self.likelihood.variance L = tf.cholesky(K) m = self.mean_f...
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], dtype=settings.float_type) * self.likelihood.variance L = tf.cholesky(K) m = self.mean_f...
[ "r", "Construct", "a", "tensorflow", "function", "to", "compute", "the", "likelihood", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/gpr.py#L64-L76
[ "def", "_build_likelihood", "(", "self", ")", ":", "K", "=", "self", ".", "kern", ".", "K", "(", "self", ".", "X", ")", "+", "tf", ".", "eye", "(", "tf", ".", "shape", "(", "self", ".", "X", ")", "[", "0", "]", ",", "dtype", "=", "settings", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
GPR._build_predict
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.
gpflow/models/gpr.py
def _build_predict(self, Xnew, full_cov=False): """ 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. """ y = self.Y - self.mean_function(self...
def _build_predict(self, Xnew, full_cov=False): """ 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. """ y = self.Y - self.mean_function(self...
[ "Xnew", "is", "a", "data", "matrix", "the", "points", "at", "which", "we", "want", "to", "predict", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/gpr.py#L80-L96
[ "def", "_build_predict", "(", "self", ",", "Xnew", ",", "full_cov", "=", "False", ")", ":", "y", "=", "self", ".", "Y", "-", "self", ".", "mean_function", "(", "self", ".", "X", ")", "Kmn", "=", "self", ".", "kern", ".", "K", "(", "self", ".", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
quadrature_expectation
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...
gpflow/expectations.py
def quadrature_expectation(p, obj1, obj2=None, num_gauss_hermite_points=None): """ 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, fea...
def quadrature_expectation(p, obj1, obj2=None, num_gauss_hermite_points=None): """ 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, fea...
[ "Compute", "the", "expectation", "<obj1", "(", "x", ")", "obj2", "(", "x", ")", ">", "_p", "(", "x", ")", "Uses", "Gauss", "-", "Hermite", "quadrature", "for", "approximate", "integration", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L49-L81
[ "def", "quadrature_expectation", "(", "p", ",", "obj1", ",", "obj2", "=", "None", ",", "num_gauss_hermite_points", "=", "None", ")", ":", "if", "isinstance", "(", "p", ",", "tuple", ")", ":", "assert", "len", "(", "p", ")", "==", "2", "if", "p", "[",...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
get_eval_func
Return the function of interest (kernel or mean) for the expectation depending on the type of :obj: and whether any features are given
gpflow/expectations.py
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 any features are given """ if feature is not None: # kernel + feature combination if not isinstance(feature, Inducing...
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 any features are given """ if feature is not None: # kernel + feature combination if not isinstance(feature, Inducing...
[ "Return", "the", "function", "of", "interest", "(", "kernel", "or", "mean", ")", "for", "the", "expectation", "depending", "on", "the", "type", "of", ":", "obj", ":", "and", "whether", "any", "features", "are", "given" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L84-L99
[ "def", "get_eval_func", "(", "obj", ",", "feature", ",", "slice", "=", "np", ".", "s_", "[", "...", "]", ")", ":", "if", "feature", "is", "not", "None", ":", "# kernel + feature combination", "if", "not", "isinstance", "(", "feature", ",", "InducingFeature...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_quadrature_expectation
General handling of quadrature expectations for Gaussians and DiagonalGaussians Fallback method for missing analytic expectations
gpflow/expectations.py
def _quadrature_expectation(p, obj1, feature1, obj2, feature2, num_gauss_hermite_points): """ General handling of quadrature expectations for Gaussians and DiagonalGaussians Fallback method for missing analytic expectations """ num_gauss_hermite_points = 100 if num_gauss_hermite_points is None else ...
def _quadrature_expectation(p, obj1, feature1, obj2, feature2, num_gauss_hermite_points): """ General handling of quadrature expectations for Gaussians and DiagonalGaussians Fallback method for missing analytic expectations """ num_gauss_hermite_points = 100 if num_gauss_hermite_points is None else ...
[ "General", "handling", "of", "quadrature", "expectations", "for", "Gaussians", "and", "DiagonalGaussians", "Fallback", "method", "for", "missing", "analytic", "expectations" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L106-L135
[ "def", "_quadrature_expectation", "(", "p", ",", "obj1", ",", "feature1", ",", "obj2", ",", "feature2", ",", "num_gauss_hermite_points", ")", ":", "num_gauss_hermite_points", "=", "100", "if", "num_gauss_hermite_points", "is", "None", "else", "num_gauss_hermite_points...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_quadrature_expectation
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 ...
gpflow/expectations.py
def _quadrature_expectation(p, obj1, feature1, obj2, feature2, num_gauss_hermite_points): """ 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 ob...
def _quadrature_expectation(p, obj1, feature1, obj2, feature2, num_gauss_hermite_points): """ 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 ob...
[ "Handling", "of", "quadrature", "expectations", "for", "Markov", "Gaussians", "(", "useful", "for", "time", "series", ")", "Fallback", "method", "for", "missing", "analytic", "expectations", "wrt", "Markov", "Gaussians", "Nota", "Bene", ":", "obj1", "is", "alway...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L142-L166
[ "def", "_quadrature_expectation", "(", "p", ",", "obj1", ",", "feature1", ",", "obj2", ",", "feature2", ",", "num_gauss_hermite_points", ")", ":", "num_gauss_hermite_points", "=", "40", "if", "num_gauss_hermite_points", "is", "None", "else", "num_gauss_hermite_points"...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
expectation
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...
gpflow/expectations.py
def expectation(p, obj1, obj2=None, nghp=None): """ 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: ...
def expectation(p, obj1, obj2=None, nghp=None): """ 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: ...
[ "Compute", "the", "expectation", "<obj1", "(", "x", ")", "obj2", "(", "x", ")", ">", "_p", "(", "x", ")", "Uses", "multiple", "-", "dispatch", "to", "select", "an", "analytical", "implementation", "if", "one", "is", "available", ".", "If", "not", "it",...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L171-L231
[ "def", "expectation", "(", "p", ",", "obj1", ",", "obj2", "=", "None", ",", "nghp", "=", "None", ")", ":", "if", "isinstance", "(", "p", ",", "tuple", ")", ":", "assert", "len", "(", "p", ")", "==", "2", "if", "p", "[", "1", "]", ".", "shape"...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
Compute the expectation: <diag(K_{X, X})>_p(X) - K_{.,.} :: RBF kernel :return: N
gpflow/expectations.py
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)
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", ":", "<diag", "(", "K_", "{", "X", "X", "}", ")", ">", "_p", "(", "X", ")", "-", "K_", "{", ".", ".", "}", "::", "RBF", "kernel" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L237-L245
[ "def", "_expectation", "(", "p", ",", "kern", ",", "none1", ",", "none2", ",", "none3", ",", "nghp", "=", "None", ")", ":", "return", "kern", ".", "Kdiag", "(", "p", ".", "mu", ")" ]
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
Compute the expectation: <K_{X, Z}>_p(X) - K_{.,.} :: RBF kernel :return: NxM
gpflow/expectations.py
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): # use only active dimensions Xcov = kern._slice_cov(p.cov) Z, Xmu = kern._slice...
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): # use only active dimensions Xcov = kern._slice_cov(p.cov) Z, Xmu = kern._slice...
[ "Compute", "the", "expectation", ":", "<K_", "{", "X", "Z", "}", ">", "_p", "(", "X", ")", "-", "K_", "{", ".", ".", "}", "::", "RBF", "kernel" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L249-L278
[ "def", "_expectation", "(", "p", ",", "kern", ",", "feat", ",", "none1", ",", "none2", ",", "nghp", "=", "None", ")", ":", "with", "params_as_tensors_for", "(", "kern", ",", "feat", ")", ":", "# use only active dimensions", "Xcov", "=", "kern", ".", "_sl...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
Compute the expectation: expectation[n] = <x_n K_{x_n, Z}>_p(x_n) - K_{.,.} :: RBF kernel :return: NxDxM
gpflow/expectations.py
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 """ Xmu, Xcov = p.mu, p.cov with tf.control_dependencies([tf.assert_equal( tf.shape(Xmu)[1], tf.constant(...
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 """ Xmu, Xcov = p.mu, p.cov with tf.control_dependencies([tf.assert_equal( tf.shape(Xmu)[1], tf.constant(...
[ "Compute", "the", "expectation", ":", "expectation", "[", "n", "]", "=", "<x_n", "K_", "{", "x_n", "Z", "}", ">", "_p", "(", "x_n", ")", "-", "K_", "{", ".", ".", "}", "::", "RBF", "kernel" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L282-L316
[ "def", "_expectation", "(", "p", ",", "mean", ",", "none", ",", "kern", ",", "feat", ",", "nghp", "=", "None", ")", ":", "Xmu", ",", "Xcov", "=", "p", ".", "mu", ",", "p", ".", "cov", "with", "tf", ".", "control_dependencies", "(", "[", "tf", "...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
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)
gpflow/expectations.py
def _expectation(p, kern1, feat1, kern2, feat2, nghp=None): """ 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) """ if kern1.on...
def _expectation(p, kern1, feat1, kern2, feat2, nghp=None): """ 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) """ if kern1.on...
[ "Compute", "the", "expectation", ":", "expectation", "[", "n", "]", "=", "<Ka_", "{", "Z1", "x_n", "}", "Kb_", "{", "x_n", "Z2", "}", ">", "_p", "(", "x_n", ")", "-", "Ka_", "{", ".", ".", "}", "Kb_", "{", ".", ".", "}", "::", "RBF", "kernels...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L359-L466
[ "def", "_expectation", "(", "p", ",", "kern1", ",", "feat1", ",", "kern2", ",", "feat2", ",", "nghp", "=", "None", ")", ":", "if", "kern1", ".", "on_separate_dims", "(", "kern2", ")", "and", "isinstance", "(", "p", ",", "DiagonalGaussian", ")", ":", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
Compute the expectation: <diag(K_{X, X})>_p(X) - K_{.,.} :: Linear kernel :return: N
gpflow/expectations.py
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): # use only active dimensions Xmu, _ = kern._slice(p.mu, None) Xcov = kern._sl...
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): # use only active dimensions Xmu, _ = kern._slice(p.mu, None) Xcov = kern._sl...
[ "Compute", "the", "expectation", ":", "<diag", "(", "K_", "{", "X", "X", "}", ")", ">", "_p", "(", "X", ")", "-", "K_", "{", ".", ".", "}", "::", "Linear", "kernel" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L472-L485
[ "def", "_expectation", "(", "p", ",", "kern", ",", "none1", ",", "none2", ",", "none3", ",", "nghp", "=", "None", ")", ":", "with", "params_as_tensors_for", "(", "kern", ")", ":", "# use only active dimensions", "Xmu", ",", "_", "=", "kern", ".", "_slice...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
Compute the expectation: <K_{X, Z}>_p(X) - K_{.,.} :: Linear kernel :return: NxM
gpflow/expectations.py
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): # use only active dimensions Z, Xmu = kern._slice(feat.Z, p.mu) return tf.m...
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): # use only active dimensions Z, Xmu = kern._slice(feat.Z, p.mu) return tf.m...
[ "Compute", "the", "expectation", ":", "<K_", "{", "X", "Z", "}", ">", "_p", "(", "X", ")", "-", "K_", "{", ".", ".", "}", "::", "Linear", "kernel" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L489-L501
[ "def", "_expectation", "(", "p", ",", "kern", ",", "feat", ",", "none1", ",", "none2", ",", "nghp", "=", "None", ")", ":", "with", "params_as_tensors_for", "(", "kern", ",", "feat", ")", ":", "# use only active dimensions", "Z", ",", "Xmu", "=", "kern", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
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
gpflow/expectations.py
def _expectation(p, kern, feat, mean, none, nghp=None): """ 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 """ Xmu, Xcov = p.mu, p.cov with ...
def _expectation(p, kern, feat, mean, none, nghp=None): """ 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 """ Xmu, Xcov = p.mu, p.cov with ...
[ "Compute", "the", "expectation", ":", "expectation", "[", "n", "]", "=", "<K_", "{", "Z", "x_n", "}", "x_", "{", "n", "+", "1", "}", "^T", ">", "_p", "(", "x_", "{", "n", ":", "n", "+", "1", "}", ")", "-", "K_", "{", ".", ".", "}", "::", ...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L528-L549
[ "def", "_expectation", "(", "p", ",", "kern", ",", "feat", ",", "mean", ",", "none", ",", "nghp", "=", "None", ")", ":", "Xmu", ",", "Xcov", "=", "p", ".", "mu", ",", "p", ".", "cov", "with", "tf", ".", "control_dependencies", "(", "[", "tf", "...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
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...
gpflow/expectations.py
def _expectation(p, kern1, feat1, kern2, feat2, nghp=None): """ 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 Diago...
def _expectation(p, kern1, feat1, kern2, feat2, nghp=None): """ 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 Diago...
[ "Compute", "the", "expectation", ":", "expectation", "[", "n", "]", "=", "<Ka_", "{", "Z1", "x_n", "}", "Kb_", "{", "x_n", "Z2", "}", ">", "_p", "(", "x_n", ")", "-", "Ka_", "{", ".", ".", "}", "Kb_", "{", ".", ".", "}", "::", "Linear", "kern...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L553-L585
[ "def", "_expectation", "(", "p", ",", "kern1", ",", "feat1", ",", "kern2", ",", "feat2", ",", "nghp", "=", "None", ")", ":", "if", "kern1", ".", "on_separate_dims", "(", "kern2", ")", "and", "isinstance", "(", "p", ",", "DiagonalGaussian", ")", ":", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
Compute the expectation: expectation[n] = <x_n K_{x_n, Z}>_p(x_n) - K_{.,} :: Linear kernel or the equivalent for MarkovGaussian :return: NxDxM
gpflow/expectations.py
def _expectation(p, mean, none, kern, feat, nghp=None): """ Compute the expectation: expectation[n] = <x_n K_{x_n, Z}>_p(x_n) - K_{.,} :: Linear kernel or the equivalent for MarkovGaussian :return: NxDxM """ return tf.matrix_transpose(expectation(p, (kern, feat), mean))
def _expectation(p, mean, none, kern, feat, nghp=None): """ Compute the expectation: expectation[n] = <x_n K_{x_n, Z}>_p(x_n) - K_{.,} :: Linear kernel or the equivalent for MarkovGaussian :return: NxDxM """ return tf.matrix_transpose(expectation(p, (kern, feat), mean))
[ "Compute", "the", "expectation", ":", "expectation", "[", "n", "]", "=", "<x_n", "K_", "{", "x_n", "Z", "}", ">", "_p", "(", "x_n", ")", "-", "K_", "{", ".", "}", "::", "Linear", "kernel", "or", "the", "equivalent", "for", "MarkovGaussian" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L593-L602
[ "def", "_expectation", "(", "p", ",", "mean", ",", "none", ",", "kern", ",", "feat", ",", "nghp", "=", "None", ")", ":", "return", "tf", ".", "matrix_transpose", "(", "expectation", "(", "p", ",", "(", "kern", ",", "feat", ")", ",", "mean", ")", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
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
gpflow/expectations.py
def _expectation(p, constant_mean, none, kern, feat, nghp=None): """ 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 """ with params_as_tensors_for(constant_mean): c =...
def _expectation(p, constant_mean, none, kern, feat, nghp=None): """ 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 """ with params_as_tensors_for(constant_mean): c =...
[ "Compute", "the", "expectation", ":", "expectation", "[", "n", "]", "=", "<m", "(", "x_n", ")", "^T", "K_", "{", "x_n", "Z", "}", ">", "_p", "(", "x_n", ")", "-", "m", "(", "x_i", ")", "=", "c", "::", "Constant", "function", "-", "K_", "{", "...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L620-L633
[ "def", "_expectation", "(", "p", ",", "constant_mean", ",", "none", ",", "kern", ",", "feat", ",", "nghp", "=", "None", ")", ":", "with", "params_as_tensors_for", "(", "constant_mean", ")", ":", "c", "=", "constant_mean", "(", "p", ".", "mu", ")", "# N...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
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
gpflow/expectations.py
def _expectation(p, linear_mean, none, kern, feat, nghp=None): """ 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 """ with params_as_tensors_for(linear_mea...
def _expectation(p, linear_mean, none, kern, feat, nghp=None): """ 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 """ with params_as_tensors_for(linear_mea...
[ "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", "funct...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L637-L654
[ "def", "_expectation", "(", "p", ",", "linear_mean", ",", "none", ",", "kern", ",", "feat", ",", "nghp", "=", "None", ")", ":", "with", "params_as_tensors_for", "(", "linear_mean", ")", ":", "N", "=", "p", ".", "mu", ".", "shape", "[", "0", "]", "....
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
Compute the expectation: <m(X)>_p(X) - m(x) :: Linear, Identity or Constant mean function :return: NxQ
gpflow/expectations.py
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 """ return mean(p.mu)
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 """ return mean(p.mu)
[ "Compute", "the", "expectation", ":", "<m", "(", "X", ")", ">", "_p", "(", "X", ")", "-", "m", "(", "x", ")", "::", "Linear", "Identity", "or", "Constant", "mean", "function" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L675-L683
[ "def", "_expectation", "(", "p", ",", "mean", ",", "none1", ",", "none2", ",", "none3", ",", "nghp", "=", "None", ")", ":", "return", "mean", "(", "p", ".", "mu", ")" ]
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
Compute the expectation: expectation[n] = <m1(x_n)^T m2(x_n)>_p(x_n) - m1(.), m2(.) :: Constant mean functions :return: NxQ1xQ2
gpflow/expectations.py
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(.) :: Constant mean functions :return: NxQ1xQ2 """ return mean1(p.mu)[:, :, None] * mean2(p.mu)[:, None, :]
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(.) :: Constant mean functions :return: NxQ1xQ2 """ return mean1(p.mu)[:, :, None] * mean2(p.mu)[:, None, :]
[ "Compute", "the", "expectation", ":", "expectation", "[", "n", "]", "=", "<m1", "(", "x_n", ")", "^T", "m2", "(", "x_n", ")", ">", "_p", "(", "x_n", ")", "-", "m1", "(", ".", ")", "m2", "(", ".", ")", "::", "Constant", "mean", "functions" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L689-L697
[ "def", "_expectation", "(", "p", ",", "mean1", ",", "none1", ",", "mean2", ",", "none2", ",", "nghp", "=", "None", ")", ":", "return", "mean1", "(", "p", ".", "mu", ")", "[", ":", ",", ":", ",", "None", "]", "*", "mean2", "(", "p", ".", "mu",...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
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
gpflow/expectations.py
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(.) :: Identity mean function - m2(.) :: Linear mean function :return: NxDxQ """ with params_as_tensors_for(mean2): N = tf.shape(p.mu)...
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(.) :: Identity mean function - m2(.) :: Linear mean function :return: NxDxQ """ with params_as_tensors_for(mean2): N = tf.shape(p.mu)...
[ "Compute", "the", "expectation", ":", "expectation", "[", "n", "]", "=", "<m1", "(", "x_n", ")", "^T", "m2", "(", "x_n", ")", ">", "_p", "(", "x_n", ")", "-", "m1", "(", ".", ")", "::", "Identity", "mean", "function", "-", "m2", "(", ".", ")", ...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L745-L760
[ "def", "_expectation", "(", "p", ",", "mean1", ",", "none1", ",", "mean2", ",", "none2", ",", "nghp", "=", "None", ")", ":", "with", "params_as_tensors_for", "(", "mean2", ")", ":", "N", "=", "tf", ".", "shape", "(", "p", ".", "mu", ")", "[", "0"...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
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
gpflow/expectations.py
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(.) :: Linear mean function - m2(.) :: Identity mean function :return: NxQxD """ with params_as_tensors_for(mean1): N = tf.shape(p.mu)...
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(.) :: Linear mean function - m2(.) :: Identity mean function :return: NxQxD """ with params_as_tensors_for(mean1): N = tf.shape(p.mu)...
[ "Compute", "the", "expectation", ":", "expectation", "[", "n", "]", "=", "<m1", "(", "x_n", ")", "^T", "m2", "(", "x_n", ")", ">", "_p", "(", "x_n", ")", "-", "m1", "(", ".", ")", "::", "Linear", "mean", "function", "-", "m2", "(", ".", ")", ...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L764-L779
[ "def", "_expectation", "(", "p", ",", "mean1", ",", "none1", ",", "mean2", ",", "none2", ",", "nghp", "=", "None", ")", ":", "with", "params_as_tensors_for", "(", "mean1", ")", ":", "N", "=", "tf", ".", "shape", "(", "p", ".", "mu", ")", "[", "0"...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
Compute the expectation: expectation[n] = <m1(x_n)^T m2(x_n)>_p(x_n) - m1(.), m2(.) :: Linear mean functions :return: NxQ1xQ2
gpflow/expectations.py
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(.) :: Linear mean functions :return: NxQ1xQ2 """ with params_as_tensors_for(mean1, mean2): e_xxt = p.cov + (p.mu[:, :, None] * p.mu[:,...
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(.) :: Linear mean functions :return: NxQ1xQ2 """ with params_as_tensors_for(mean1, mean2): e_xxt = p.cov + (p.mu[:, :, None] * p.mu[:,...
[ "Compute", "the", "expectation", ":", "expectation", "[", "n", "]", "=", "<m1", "(", "x_n", ")", "^T", "m2", "(", "x_n", ")", ">", "_p", "(", "x_n", ")", "-", "m1", "(", ".", ")", "m2", "(", ".", ")", "::", "Linear", "mean", "functions" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L783-L798
[ "def", "_expectation", "(", "p", ",", "mean1", ",", "none1", ",", "mean2", ",", "none2", ",", "nghp", "=", "None", ")", ":", "with", "params_as_tensors_for", "(", "mean1", ",", "mean2", ")", ":", "e_xxt", "=", "p", ".", "cov", "+", "(", "p", ".", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
r""" Compute the expectation: <\Sum_i Ki_{X, Z}>_p(X) - \Sum_i Ki_{.,.} :: Sum kernel :return: NxM
gpflow/expectations.py
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 """ return functools.reduce(tf.add, [ expectation(p, (k, feat), nghp=nghp) for k in kern.kernels])
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 """ return functools.reduce(tf.add, [ expectation(p, (k, feat), nghp=nghp) for k in kern.kernels])
[ "r", "Compute", "the", "expectation", ":", "<", "\\", "Sum_i", "Ki_", "{", "X", "Z", "}", ">", "_p", "(", "X", ")", "-", "\\", "Sum_i", "Ki_", "{", ".", ".", "}", "::", "Sum", "kernel" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L817-L826
[ "def", "_expectation", "(", "p", ",", "kern", ",", "feat", ",", "none2", ",", "none3", ",", "nghp", "=", "None", ")", ":", "return", "functools", ".", "reduce", "(", "tf", ".", "add", ",", "[", "expectation", "(", "p", ",", "(", "k", ",", "feat",...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
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
gpflow/expectations.py
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) - \Sum_i Ki_{.,.} :: Sum kernel :return: NxQxM """ return functools.reduce(tf.add, [ expectation(p, mean, (k, feat), nghp=nghp) for k in ...
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) - \Sum_i Ki_{.,.} :: Sum kernel :return: NxQxM """ return functools.reduce(tf.add, [ expectation(p, mean, (k, feat), nghp=nghp) for k in ...
[ "r", "Compute", "the", "expectation", ":", "expectation", "[", "n", "]", "=", "<m", "(", "x_n", ")", "^T", "(", "\\", "Sum_i", "Ki_", "{", "x_n", "Z", "}", ")", ">", "_p", "(", "x_n", ")", "-", "\\", "Sum_i", "Ki_", "{", ".", ".", "}", "::", ...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L832-L841
[ "def", "_expectation", "(", "p", ",", "mean", ",", "none", ",", "kern", ",", "feat", ",", "nghp", "=", "None", ")", ":", "return", "functools", ".", "reduce", "(", "tf", ".", "add", ",", "[", "expectation", "(", "p", ",", "mean", ",", "(", "k", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
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
gpflow/expectations.py
def _expectation(p, kern1, feat1, kern2, feat2, nghp=None): 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 """ crossexps = [] if kern1 == kern2 and feat1 ...
def _expectation(p, kern1, feat1, kern2, feat2, nghp=None): 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 """ crossexps = [] if kern1 == kern2 and feat1 ...
[ "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",...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L858-L880
[ "def", "_expectation", "(", "p", ",", "kern1", ",", "feat1", ",", "kern2", ",", "feat2", ",", "nghp", "=", "None", ")", ":", "crossexps", "=", "[", "]", "if", "kern1", "==", "kern2", "and", "feat1", "==", "feat2", ":", "# avoid duplicate computation by u...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
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...
gpflow/expectations.py
def _expectation(p, rbf_kern, feat1, lin_kern, feat2, nghp=None): """ 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...
def _expectation(p, rbf_kern, feat1, lin_kern, feat2, nghp=None): """ 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...
[ "Compute", "the", "expectation", ":", "expectation", "[", "n", "]", "=", "<Ka_", "{", "Z1", "x_n", "}", "Kb_", "{", "x_n", "Z2", "}", ">", "_p", "(", "x_n", ")", "-", "K_lin_", "{", ".", ".", "}", "::", "RBF", "kernel", "-", "K_rbf_", "{", ".",...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L886-L942
[ "def", "_expectation", "(", "p", ",", "rbf_kern", ",", "feat1", ",", "lin_kern", ",", "feat2", ",", "nghp", "=", "None", ")", ":", "if", "rbf_kern", ".", "on_separate_dims", "(", "lin_kern", ")", "and", "isinstance", "(", "p", ",", "DiagonalGaussian", ")...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
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...
gpflow/expectations.py
def _expectation(p, lin_kern, feat1, rbf_kern, feat2, nghp=None): """ 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...
def _expectation(p, lin_kern, feat1, rbf_kern, feat2, nghp=None): """ 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...
[ "Compute", "the", "expectation", ":", "expectation", "[", "n", "]", "=", "<Ka_", "{", "Z1", "x_n", "}", "Kb_", "{", "x_n", "Z2", "}", ">", "_p", "(", "x_n", ")", "-", "K_lin_", "{", ".", ".", "}", "::", "Linear", "kernel", "-", "K_rbf_", "{", "...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L946-L957
[ "def", "_expectation", "(", "p", ",", "lin_kern", ",", "feat1", ",", "rbf_kern", ",", "feat2", ",", "nghp", "=", "None", ")", ":", "return", "tf", ".", "matrix_transpose", "(", "expectation", "(", "p", ",", "(", "rbf_kern", ",", "feat2", ")", ",", "(...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
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
gpflow/expectations.py
def _expectation(p, kern, none1, none2, none3, nghp=None): 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) :retur...
def _expectation(p, kern, none1, none2, none3, nghp=None): 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) :retur...
[ "r", "Compute", "the", "expectation", ":", "<", "\\", "HadamardProd_i", "diag", "(", "Ki_", "{", "X", "[", ":", "active_dims_i", "]", "X", "[", ":", "active_dims_i", "]", "}", ")", ">", "_p", "(", "X", ")", "-", "\\", "HadamardProd_i", "Ki_", "{", ...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L966-L980
[ "def", "_expectation", "(", "p", ",", "kern", ",", "none1", ",", "none2", ",", "none3", ",", "nghp", "=", "None", ")", ":", "if", "not", "kern", ".", "on_separate_dimensions", ":", "raise", "NotImplementedError", "(", "\"Product currently needs to be defined on ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
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...
gpflow/expectations.py
def _expectation(p, kern1, feat1, kern2, feat2, 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]...
def _expectation(p, kern1, feat1, kern2, feat2, 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]...
[ "r", "Compute", "the", "expectation", ":", "expectation", "[", "n", "]", "=", "<", "prodK_", "{", "Z", "x_n", "}", "prodK_", "{", "x_n", "Z", "}", ">", "_p", "(", "x_n", ")", "=", "<", "(", "\\", "HadamardProd_i", "Ki_", "{", "Z", "[", ":", "ac...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L1002-L1028
[ "def", "_expectation", "(", "p", ",", "kern1", ",", "feat1", ",", "kern2", ",", "feat2", ",", "nghp", "=", "None", ")", ":", "if", "feat1", "!=", "feat2", ":", "raise", "NotImplementedError", "(", "\"Different features are not supported.\"", ")", "if", "kern...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_expectation
Nota Bene: if only one object is passed, obj1 is associated with x_n, whereas obj2 with x_{n+1}
gpflow/expectations.py
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 = Gaussian(p.mu[:-1], p.cov[0, :-1]) return expectation(gaussian, (obj1, feat1), nghp=nghp) ...
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 = Gaussian(p.mu[:-1], p.cov[0, :-1]) return expectation(gaussian, (obj1, feat1), nghp=nghp) ...
[ "Nota", "Bene", ":", "if", "only", "one", "object", "is", "passed", "obj1", "is", "associated", "with", "x_n", "whereas", "obj2", "with", "x_", "{", "n", "+", "1", "}" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/expectations.py#L1047-L1060
[ "def", "_expectation", "(", "p", ",", "obj1", ",", "feat1", ",", "obj2", ",", "feat2", ",", "nghp", "=", "None", ")", ":", "if", "obj2", "is", "None", ":", "gaussian", "=", "Gaussian", "(", "p", ".", "mu", "[", ":", "-", "1", "]", ",", "p", "...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
HMC.sample
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...
gpflow/training/hmc.py
def sample(self, model, num_samples, epsilon, lmin=1, lmax=1, thin=1, burn=0, session=None, initialize=True, anchor=True, logprobs=True): """ A straight-forward HMC implementation. The mass matrix is assumed to be the identity. The gpflow mod...
def sample(self, model, num_samples, epsilon, lmin=1, lmax=1, thin=1, burn=0, session=None, initialize=True, anchor=True, logprobs=True): """ A straight-forward HMC implementation. The mass matrix is assumed to be the identity. The gpflow mod...
[ "A", "straight", "-", "forward", "HMC", "implementation", ".", "The", "mass", "matrix", "is", "assumed", "to", "be", "the", "identity", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/hmc.py#L24-L124
[ "def", "sample", "(", "self", ",", "model", ",", "num_samples", ",", "epsilon", ",", "lmin", "=", "1", ",", "lmax", "=", "1", ",", "thin", "=", "1", ",", "burn", "=", "0", ",", "session", "=", "None", ",", "initialize", "=", "True", ",", "anchor"...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
Likelihood.predict_mean_and_var
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...
gpflow/likelihoods.py
def predict_mean_and_var(self, Fmu, Fvar): 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\in...
def predict_mean_and_var(self, Fmu, Fvar): 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\in...
[ "r", "Given", "a", "Normal", "distribution", "for", "the", "latent", "function", "return", "the", "mean", "of", "Y" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/likelihoods.py#L76-L104
[ "def", "predict_mean_and_var", "(", "self", ",", "Fmu", ",", "Fvar", ")", ":", "integrand2", "=", "lambda", "*", "X", ":", "self", ".", "conditional_variance", "(", "*", "X", ")", "+", "tf", ".", "square", "(", "self", ".", "conditional_mean", "(", "*"...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
Likelihood.predict_density
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=...
gpflow/likelihoods.py
def predict_density(self, Fmu, Fvar, Y): 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 t...
def predict_density(self, Fmu, Fvar, Y): 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 t...
[ "r", "Given", "a", "Normal", "distribution", "for", "the", "latent", "function", "and", "a", "datum", "Y", "compute", "the", "log", "predictive", "density", "of", "Y", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/likelihoods.py#L106-L127
[ "def", "predict_density", "(", "self", ",", "Fmu", ",", "Fvar", ",", "Y", ")", ":", "return", "ndiagquad", "(", "self", ".", "logp", ",", "self", ".", "num_gauss_hermite_points", ",", "Fmu", ",", "Fvar", ",", "logspace", "=", "True", ",", "Y", "=", "...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
Likelihood.variational_expectations
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...
gpflow/likelihoods.py
def variational_expectations(self, Fmu, Fvar, 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 ...
def variational_expectations(self, Fmu, Fvar, 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 ...
[ "r", "Compute", "the", "expected", "log", "density", "of", "the", "data", "given", "a", "Gaussian", "distribution", "for", "the", "function", "values", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/likelihoods.py#L129-L151
[ "def", "variational_expectations", "(", "self", ",", "Fmu", ",", "Fvar", ",", "Y", ")", ":", "return", "ndiagquad", "(", "self", ".", "logp", ",", "self", ".", "num_gauss_hermite_points", ",", "Fmu", ",", "Fvar", ",", "Y", "=", "Y", ")" ]
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
SwitchedLikelihood._partition_and_stitch
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.
gpflow/likelihoods.py
def _partition_and_stitch(self, args, func_name): """ 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 releva...
def _partition_and_stitch(self, args, func_name): """ 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 releva...
[ "args", "is", "a", "list", "of", "tensors", "to", "be", "passed", "to", "self", ".", "likelihoods", ".", "<func_name", ">" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/likelihoods.py#L506-L534
[ "def", "_partition_and_stitch", "(", "self", ",", "args", ",", "func_name", ")", ":", "# get the index from Y", "Y", "=", "args", "[", "-", "1", "]", "ind", "=", "Y", "[", ":", ",", "-", "1", "]", "ind", "=", "tf", ".", "cast", "(", "ind", ",", "...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
Ordinal._make_phi
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.
gpflow/likelihoods.py
def _make_phi(self, F): """ 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. """ scaled_bi...
def _make_phi(self, F): """ 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. """ scaled_bi...
[ "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...
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/likelihoods.py#L604-L615
[ "def", "_make_phi", "(", "self", ",", "F", ")", ":", "scaled_bins_left", "=", "tf", ".", "concat", "(", "[", "self", ".", "bin_edges", "/", "self", ".", "sigma", ",", "np", ".", "array", "(", "[", "np", ".", "inf", "]", ")", "]", ",", "0", ")",...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
MonteCarloLikelihood.predict_mean_and_var
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...
gpflow/likelihoods.py
def predict_mean_and_var(self, Fmu, Fvar, epsilon=None): 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 ...
def predict_mean_and_var(self, Fmu, Fvar, epsilon=None): 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 ...
[ "r", "Given", "a", "Normal", "distribution", "for", "the", "latent", "function", "return", "the", "mean", "of", "Y" ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/likelihoods.py#L639-L665
[ "def", "predict_mean_and_var", "(", "self", ",", "Fmu", ",", "Fvar", ",", "epsilon", "=", "None", ")", ":", "integrand2", "=", "lambda", "*", "X", ":", "self", ".", "conditional_variance", "(", "*", "X", ")", "+", "tf", ".", "square", "(", "self", "....
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
MonteCarloLikelihood.predict_density
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=...
gpflow/likelihoods.py
def predict_density(self, Fmu, Fvar, Y, epsilon=None): 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 met...
def predict_density(self, Fmu, Fvar, Y, epsilon=None): 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 met...
[ "r", "Given", "a", "Normal", "distribution", "for", "the", "latent", "function", "and", "a", "datum", "Y", "compute", "the", "log", "predictive", "density", "of", "Y", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/likelihoods.py#L667-L685
[ "def", "predict_density", "(", "self", ",", "Fmu", ",", "Fvar", ",", "Y", ",", "epsilon", "=", "None", ")", ":", "return", "self", ".", "_mc_quadrature", "(", "self", ".", "logp", ",", "Fmu", ",", "Fvar", ",", "Y", "=", "Y", ",", "logspace", "=", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
MonteCarloLikelihood.variational_expectations
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...
gpflow/likelihoods.py
def variational_expectations(self, Fmu, Fvar, Y, epsilon=None): 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)...
def variational_expectations(self, Fmu, Fvar, Y, epsilon=None): 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)...
[ "r", "Compute", "the", "expected", "log", "density", "of", "the", "data", "given", "a", "Gaussian", "distribution", "for", "the", "function", "values", "." ]
GPflow/GPflow
python
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/likelihoods.py#L687-L706
[ "def", "variational_expectations", "(", "self", ",", "Fmu", ",", "Fvar", ",", "Y", ",", "epsilon", "=", "None", ")", ":", "return", "self", ".", "_mc_quadrature", "(", "self", ".", "logp", ",", "Fmu", ",", "Fvar", ",", "Y", "=", "Y", ",", "epsilon", ...
549394f0b1b0696c7b521a065e49bdae6e7acf27
train
_absorb_z_into_w
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...
cirq/optimizers/eject_phased_paulis.py
def _absorb_z_into_w(moment_index: int, op: ops.Operation, state: _OptimizerState) -> None: """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)────...
def _absorb_z_into_w(moment_index: int, op: ops.Operation, state: _OptimizerState) -> None: """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)────...
[ "Absorbs", "a", "Z^t", "gate", "into", "a", "W", "(", "a", ")", "flip", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/optimizers/eject_phased_paulis.py#L115-L133
[ "def", "_absorb_z_into_w", "(", "moment_index", ":", "int", ",", "op", ":", "ops", ".", "Operation", ",", "state", ":", "_OptimizerState", ")", "->", "None", ":", "t", "=", "cast", "(", "float", ",", "_try_get_known_z_half_turns", "(", "op", ")", ")", "q...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_potential_cross_whole_w
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─── ...
cirq/optimizers/eject_phased_paulis.py
def _potential_cross_whole_w(moment_index: int, op: ops.Operation, tolerance: float, state: _OptimizerState) -> None: """Grabs or cancels a held W gate against an existing W gate. [Where W(a) is shorthand for PhasedX(phase_e...
def _potential_cross_whole_w(moment_index: int, op: ops.Operation, tolerance: float, state: _OptimizerState) -> None: """Grabs or cancels a held W gate against an existing W gate. [Where W(a) is shorthand for PhasedX(phase_e...
[ "Grabs", "or", "cancels", "a", "held", "W", "gate", "against", "an", "existing", "W", "gate", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/optimizers/eject_phased_paulis.py#L163-L195
[ "def", "_potential_cross_whole_w", "(", "moment_index", ":", "int", ",", "op", ":", "ops", ".", "Operation", ",", "tolerance", ":", "float", ",", "state", ":", "_OptimizerState", ")", "->", "None", ":", "state", ".", "deletions", ".", "append", "(", "(", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_potential_cross_partial_w
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-...
cirq/optimizers/eject_phased_paulis.py
def _potential_cross_partial_w(moment_index: int, op: ops.Operation, state: _OptimizerState) -> None: """Cross the held W over a partial W gate. [Where W(a) is shorthand for PhasedX(phase_exponent=a).] Uses the following identity: ───W(...
def _potential_cross_partial_w(moment_index: int, op: ops.Operation, state: _OptimizerState) -> None: """Cross the held W over a partial W gate. [Where W(a) is shorthand for PhasedX(phase_exponent=a).] Uses the following identity: ───W(...
[ "Cross", "the", "held", "W", "over", "a", "partial", "W", "gate", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/optimizers/eject_phased_paulis.py#L198-L222
[ "def", "_potential_cross_partial_w", "(", "moment_index", ":", "int", ",", "op", ":", "ops", ".", "Operation", ",", "state", ":", "_OptimizerState", ")", "->", "None", ":", "a", "=", "state", ".", "held_w_phases", ".", "get", "(", "op", ".", "qubits", "[...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_single_cross_over_cz
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...
cirq/optimizers/eject_phased_paulis.py
def _single_cross_over_cz(moment_index: int, op: ops.Operation, qubit_with_w: ops.Qid, state: _OptimizerState) -> None: """Crosses exactly one W flip over a partial CZ. [Where W(a) is shorthand for PhasedX(phase_exponent=a).] Us...
def _single_cross_over_cz(moment_index: int, op: ops.Operation, qubit_with_w: ops.Qid, state: _OptimizerState) -> None: """Crosses exactly one W flip over a partial CZ. [Where W(a) is shorthand for PhasedX(phase_exponent=a).] Us...
[ "Crosses", "exactly", "one", "W", "flip", "over", "a", "partial", "CZ", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/optimizers/eject_phased_paulis.py#L225-L267
[ "def", "_single_cross_over_cz", "(", "moment_index", ":", "int", ",", "op", ":", "ops", ".", "Operation", ",", "qubit_with_w", ":", "ops", ".", "Qid", ",", "state", ":", "_OptimizerState", ")", "->", "None", ":", "t", "=", "cast", "(", "float", ",", "_...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_double_cross_over_cz
Crosses two W flips over a partial CZ. [Where W(a) is shorthand for PhasedX(phase_exponent=a).] Uses the following identity: ───W(a)───@───── │ ───W(b)───@^t─── ≡ ──────────@────────────W(a)─── │ (single-cross top W over CZ) ...
cirq/optimizers/eject_phased_paulis.py
def _double_cross_over_cz(op: ops.Operation, state: _OptimizerState) -> None: """Crosses two W flips over a partial CZ. [Where W(a) is shorthand for PhasedX(phase_exponent=a).] Uses the following identity: ───W(a)───@───── │ ───W(b)───@^t─── ...
def _double_cross_over_cz(op: ops.Operation, state: _OptimizerState) -> None: """Crosses two W flips over a partial CZ. [Where W(a) is shorthand for PhasedX(phase_exponent=a).] Uses the following identity: ───W(a)───@───── │ ───W(b)───@^t─── ...
[ "Crosses", "two", "W", "flips", "over", "a", "partial", "CZ", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/optimizers/eject_phased_paulis.py#L270-L308
[ "def", "_double_cross_over_cz", "(", "op", ":", "ops", ".", "Operation", ",", "state", ":", "_OptimizerState", ")", "->", "None", ":", "t", "=", "cast", "(", "float", ",", "_try_get_known_cz_half_turns", "(", "op", ")", ")", "for", "q", "in", "op", ".", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
validate_probability
Validates that a probability is between 0 and 1 inclusively. Args: p: The value to validate. p_str: What to call the probability in error messages. Returns: The probability p if the probability if valid. Raises: ValueError if the probability is invalid.
cirq/value/probability.py
def validate_probability(p: float, p_str: str) -> float: """Validates that a probability is between 0 and 1 inclusively. Args: p: The value to validate. p_str: What to call the probability in error messages. Returns: The probability p if the probability if valid. Raises: ...
def validate_probability(p: float, p_str: str) -> float: """Validates that a probability is between 0 and 1 inclusively. Args: p: The value to validate. p_str: What to call the probability in error messages. Returns: The probability p if the probability if valid. Raises: ...
[ "Validates", "that", "a", "probability", "is", "between", "0", "and", "1", "inclusively", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/value/probability.py#L18-L35
[ "def", "validate_probability", "(", "p", ":", "float", ",", "p_str", ":", "str", ")", "->", "float", ":", "if", "p", "<", "0", ":", "raise", "ValueError", "(", "'{} was less than 0.'", ".", "format", "(", "p_str", ")", ")", "elif", "p", ">", "1", ":"...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
phase_by
Returns a phased version of the effect. For example, an X gate phased by 90 degrees would be a Y gate. This works by calling `val`'s _phase_by_ method and returning the result. Args: val: The value to describe with a unitary matrix. phase_turns: The amount to phase the gate, in fractio...
cirq/protocols/phase.py
def phase_by(val: Any, phase_turns: float, qubit_index: int, default: TDefault = RaiseTypeErrorIfNotProvided): """Returns a phased version of the effect. For example, an X gate phased by 90 degrees would be a Y gate. This works by calling `val`'s _phase_by_ method and returning the result....
def phase_by(val: Any, phase_turns: float, qubit_index: int, default: TDefault = RaiseTypeErrorIfNotProvided): """Returns a phased version of the effect. For example, an X gate phased by 90 degrees would be a Y gate. This works by calling `val`'s _phase_by_ method and returning the result....
[ "Returns", "a", "phased", "version", "of", "the", "effect", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/phase.py#L47-L89
[ "def", "phase_by", "(", "val", ":", "Any", ",", "phase_turns", ":", "float", ",", "qubit_index", ":", "int", ",", "default", ":", "TDefault", "=", "RaiseTypeErrorIfNotProvided", ")", ":", "getter", "=", "getattr", "(", "val", ",", "'_phase_by_'", ",", "Non...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
SingleQubitGate.on_each
Returns a list of operations apply this gate to each of the targets. Args: *targets: The qubits to apply this gate to. Returns: Operations applying this gate to the target qubits. Raises: ValueError if targets are not instances of Qid.
cirq/ops/gate_features.py
def on_each(self, *targets: raw_types.Qid) -> op_tree.OP_TREE: """Returns a list of operations apply this gate to each of the targets. Args: *targets: The qubits to apply this gate to. Returns: Operations applying this gate to the target qubits. Raises: ...
def on_each(self, *targets: raw_types.Qid) -> op_tree.OP_TREE: """Returns a list of operations apply this gate to each of the targets. Args: *targets: The qubits to apply this gate to. Returns: Operations applying this gate to the target qubits. Raises: ...
[ "Returns", "a", "list", "of", "operations", "apply", "this", "gate", "to", "each", "of", "the", "targets", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/gate_features.py#L38-L50
[ "def", "on_each", "(", "self", ",", "*", "targets", ":", "raw_types", ".", "Qid", ")", "->", "op_tree", ".", "OP_TREE", ":", "return", "[", "self", ".", "on", "(", "target", ")", "for", "target", "in", "targets", "]" ]
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
engine_from_environment
Returns an Engine instance configured using environment variables. If the environment variables are set, but incorrect, an authentication failure will occur when attempting to run jobs on the engine. Required Environment Variables: QUANTUM_ENGINE_PROJECT: The name of a google cloud project, with t...
cirq/google/engine/env_config.py
def engine_from_environment() -> Engine: """Returns an Engine instance configured using environment variables. If the environment variables are set, but incorrect, an authentication failure will occur when attempting to run jobs on the engine. Required Environment Variables: QUANTUM_ENGINE_PRO...
def engine_from_environment() -> Engine: """Returns an Engine instance configured using environment variables. If the environment variables are set, but incorrect, an authentication failure will occur when attempting to run jobs on the engine. Required Environment Variables: QUANTUM_ENGINE_PRO...
[ "Returns", "an", "Engine", "instance", "configured", "using", "environment", "variables", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/engine/env_config.py#L25-L47
[ "def", "engine_from_environment", "(", ")", "->", "Engine", ":", "api_key", "=", "os", ".", "environ", ".", "get", "(", "ENV_API_KEY", ")", "if", "not", "api_key", ":", "raise", "EnvironmentError", "(", "'Environment variable {} is not set.'", ".", "format", "("...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
plot_state_histogram
Plot the state histogram from a single result with repetitions. States is a bitstring representation of all the qubit states in a single result. Currently this function assumes each measurement gate applies to only a single qubit. Args: result: The trial results to plot. Returns: ...
cirq/study/visualize.py
def plot_state_histogram(result: trial_result.TrialResult) -> np.ndarray: """Plot the state histogram from a single result with repetitions. States is a bitstring representation of all the qubit states in a single result. Currently this function assumes each measurement gate applies to only a singl...
def plot_state_histogram(result: trial_result.TrialResult) -> np.ndarray: """Plot the state histogram from a single result with repetitions. States is a bitstring representation of all the qubit states in a single result. Currently this function assumes each measurement gate applies to only a singl...
[ "Plot", "the", "state", "histogram", "from", "a", "single", "result", "with", "repetitions", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/study/visualize.py#L22-L66
[ "def", "plot_state_histogram", "(", "result", ":", "trial_result", ".", "TrialResult", ")", "->", "np", ".", "ndarray", ":", "# pyplot import is deferred because it requires a system dependency", "# (python3-tk) that `python -m pip install cirq` can't handle for the user.", "# This a...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
sweep_to_proto_dict
Converts sweep into an equivalent protobuf representation.
cirq/google/params.py
def sweep_to_proto_dict(sweep: Sweep, repetitions: int=1) -> Dict: """Converts sweep into an equivalent protobuf representation.""" msg = {} # type: Dict if not sweep == UnitSweep: sweep = _to_zip_product(sweep) msg['sweep'] = { 'factors': [_sweep_zip_to_proto_dict(cast(Zip, fac...
def sweep_to_proto_dict(sweep: Sweep, repetitions: int=1) -> Dict: """Converts sweep into an equivalent protobuf representation.""" msg = {} # type: Dict if not sweep == UnitSweep: sweep = _to_zip_product(sweep) msg['sweep'] = { 'factors': [_sweep_zip_to_proto_dict(cast(Zip, fac...
[ "Converts", "sweep", "into", "an", "equivalent", "protobuf", "representation", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/params.py#L21-L31
[ "def", "sweep_to_proto_dict", "(", "sweep", ":", "Sweep", ",", "repetitions", ":", "int", "=", "1", ")", "->", "Dict", ":", "msg", "=", "{", "}", "# type: Dict", "if", "not", "sweep", "==", "UnitSweep", ":", "sweep", "=", "_to_zip_product", "(", "sweep",...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_to_zip_product
Converts sweep to a product of zips of single sweeps, if possible.
cirq/google/params.py
def _to_zip_product(sweep: Sweep) -> Product: """Converts sweep to a product of zips of single sweeps, if possible.""" if not isinstance(sweep, Product): sweep = Product(sweep) if not all(isinstance(f, Zip) for f in sweep.factors): factors = [f if isinstance(f, Zip) else Zip(f) for f in swee...
def _to_zip_product(sweep: Sweep) -> Product: """Converts sweep to a product of zips of single sweeps, if possible.""" if not isinstance(sweep, Product): sweep = Product(sweep) if not all(isinstance(f, Zip) for f in sweep.factors): factors = [f if isinstance(f, Zip) else Zip(f) for f in swee...
[ "Converts", "sweep", "to", "a", "product", "of", "zips", "of", "single", "sweeps", "if", "possible", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/params.py#L35-L47
[ "def", "_to_zip_product", "(", "sweep", ":", "Sweep", ")", "->", "Product", ":", "if", "not", "isinstance", "(", "sweep", ",", "Product", ")", ":", "sweep", "=", "Product", "(", "sweep", ")", "if", "not", "all", "(", "isinstance", "(", "f", ",", "Zip...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
PeriodicValue._approx_eq_
Implementation of `SupportsApproximateEquality` protocol.
cirq/value/periodic_value.py
def _approx_eq_(self, other: Any, atol: float) -> bool: """Implementation of `SupportsApproximateEquality` protocol.""" if not isinstance(other, type(self)): return NotImplemented #self.value = value % period in __init__() creates a Mod if isinstance(other.value, sympy.Mod):...
def _approx_eq_(self, other: Any, atol: float) -> bool: """Implementation of `SupportsApproximateEquality` protocol.""" if not isinstance(other, type(self)): return NotImplemented #self.value = value % period in __init__() creates a Mod if isinstance(other.value, sympy.Mod):...
[ "Implementation", "of", "SupportsApproximateEquality", "protocol", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/value/periodic_value.py#L57-L78
[ "def", "_approx_eq_", "(", "self", ",", "other", ":", "Any", ",", "atol", ":", "float", ")", "->", "bool", ":", "if", "not", "isinstance", "(", "other", ",", "type", "(", "self", ")", ")", ":", "return", "NotImplemented", "#self.value = value % period in _...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
remove_redundant_acquaintance_opportunities
Removes redundant acquaintance opportunities.
cirq/contrib/acquaintance/optimizers.py
def remove_redundant_acquaintance_opportunities( strategy: circuits.Circuit) -> int: """Removes redundant acquaintance opportunities.""" if not is_acquaintance_strategy(strategy): raise TypeError('not is_acquaintance_strategy(circuit)') qubits = sorted(strategy.all_qubits()) mapping = {...
def remove_redundant_acquaintance_opportunities( strategy: circuits.Circuit) -> int: """Removes redundant acquaintance opportunities.""" if not is_acquaintance_strategy(strategy): raise TypeError('not is_acquaintance_strategy(circuit)') qubits = sorted(strategy.all_qubits()) mapping = {...
[ "Removes", "redundant", "acquaintance", "opportunities", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/acquaintance/optimizers.py#L31-L61
[ "def", "remove_redundant_acquaintance_opportunities", "(", "strategy", ":", "circuits", ".", "Circuit", ")", "->", "int", ":", "if", "not", "is_acquaintance_strategy", "(", "strategy", ")", ":", "raise", "TypeError", "(", "'not is_acquaintance_strategy(circuit)'", ")", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
SimulatesSamples.run_sweep
Runs the supplied Circuit or Schedule, mimicking quantum hardware. In contrast to run, this allows for sweeping over different parameter values. Args: program: The circuit or schedule to simulate. params: Parameters to run with the program. repetitions: The ...
cirq/sim/simulator.py
def run_sweep( self, program: Union[circuits.Circuit, schedules.Schedule], params: study.Sweepable, repetitions: int = 1, ) -> List[study.TrialResult]: """Runs the supplied Circuit or Schedule, mimicking quantum hardware. In contrast to run, this allows for sweeping ...
def run_sweep( self, program: Union[circuits.Circuit, schedules.Schedule], params: study.Sweepable, repetitions: int = 1, ) -> List[study.TrialResult]: """Runs the supplied Circuit or Schedule, mimicking quantum hardware. In contrast to run, this allows for sweeping ...
[ "Runs", "the", "supplied", "Circuit", "or", "Schedule", "mimicking", "quantum", "hardware", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/simulator.py#L45-L77
[ "def", "run_sweep", "(", "self", ",", "program", ":", "Union", "[", "circuits", ".", "Circuit", ",", "schedules", ".", "Schedule", "]", ",", "params", ":", "study", ".", "Sweepable", ",", "repetitions", ":", "int", "=", "1", ",", ")", "->", "List", "...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
SimulatesSamples._run
Run a simulation, mimicking quantum hardware. Args: circuit: The circuit to simulate. param_resolver: Parameters to run with the program. repetitions: Number of times to repeat the run. Returns: A dictionary from measurement gate key to measurement ...
cirq/sim/simulator.py
def _run( self, circuit: circuits.Circuit, param_resolver: study.ParamResolver, repetitions: int ) -> Dict[str, np.ndarray]: """Run a simulation, mimicking quantum hardware. Args: circuit: The circuit to simulate. param_resolver: Parameters to...
def _run( self, circuit: circuits.Circuit, param_resolver: study.ParamResolver, repetitions: int ) -> Dict[str, np.ndarray]: """Run a simulation, mimicking quantum hardware. Args: circuit: The circuit to simulate. param_resolver: Parameters to...
[ "Run", "a", "simulation", "mimicking", "quantum", "hardware", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/simulator.py#L80-L100
[ "def", "_run", "(", "self", ",", "circuit", ":", "circuits", ".", "Circuit", ",", "param_resolver", ":", "study", ".", "ParamResolver", ",", "repetitions", ":", "int", ")", "->", "Dict", "[", "str", ",", "np", ".", "ndarray", "]", ":", "raise", "NotImp...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
SimulatesSamples.compute_samples_displays
Computes SamplesDisplays in the supplied Circuit or Schedule. Args: program: The circuit or schedule to simulate. param_resolver: Parameters to run with the program. Returns: ComputeDisplaysResult for the simulation.
cirq/sim/simulator.py
def compute_samples_displays( self, program: Union[circuits.Circuit, schedules.Schedule], param_resolver: 'study.ParamResolverOrSimilarType' = None, ) -> study.ComputeDisplaysResult: """Computes SamplesDisplays in the supplied Circuit or Schedule. Args: ...
def compute_samples_displays( self, program: Union[circuits.Circuit, schedules.Schedule], param_resolver: 'study.ParamResolverOrSimilarType' = None, ) -> study.ComputeDisplaysResult: """Computes SamplesDisplays in the supplied Circuit or Schedule. Args: ...
[ "Computes", "SamplesDisplays", "in", "the", "supplied", "Circuit", "or", "Schedule", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/simulator.py#L102-L118
[ "def", "compute_samples_displays", "(", "self", ",", "program", ":", "Union", "[", "circuits", ".", "Circuit", ",", "schedules", ".", "Schedule", "]", ",", "param_resolver", ":", "'study.ParamResolverOrSimilarType'", "=", "None", ",", ")", "->", "study", ".", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
SimulatesSamples.compute_samples_displays_sweep
Computes SamplesDisplays in the supplied Circuit or Schedule. In contrast to `compute_displays`, this allows for sweeping over different parameter values. Args: program: The circuit or schedule to simulate. params: Parameters to run with the program. Returns: ...
cirq/sim/simulator.py
def compute_samples_displays_sweep( self, program: Union[circuits.Circuit, schedules.Schedule], params: Optional[study.Sweepable] = None ) -> List[study.ComputeDisplaysResult]: """Computes SamplesDisplays in the supplied Circuit or Schedule. In contrast to `compu...
def compute_samples_displays_sweep( self, program: Union[circuits.Circuit, schedules.Schedule], params: Optional[study.Sweepable] = None ) -> List[study.ComputeDisplaysResult]: """Computes SamplesDisplays in the supplied Circuit or Schedule. In contrast to `compu...
[ "Computes", "SamplesDisplays", "in", "the", "supplied", "Circuit", "or", "Schedule", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/simulator.py#L120-L168
[ "def", "compute_samples_displays_sweep", "(", "self", ",", "program", ":", "Union", "[", "circuits", ".", "Circuit", ",", "schedules", ".", "Schedule", "]", ",", "params", ":", "Optional", "[", "study", ".", "Sweepable", "]", "=", "None", ")", "->", "List"...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
SimulatesFinalState.simulate
Simulates the supplied Circuit or Schedule. This method returns a result which allows access to the entire wave function. Args: program: The circuit or schedule to simulate. param_resolver: Parameters to run with the program. qubit_order: Determines the cano...
cirq/sim/simulator.py
def simulate( self, program: Union[circuits.Circuit, schedules.Schedule], param_resolver: 'study.ParamResolverOrSimilarType' = None, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, initial_state: Any = None, ) -> 'SimulationTrialResult': """Simulates the s...
def simulate( self, program: Union[circuits.Circuit, schedules.Schedule], param_resolver: 'study.ParamResolverOrSimilarType' = None, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, initial_state: Any = None, ) -> 'SimulationTrialResult': """Simulates the s...
[ "Simulates", "the", "supplied", "Circuit", "or", "Schedule", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/simulator.py#L182-L211
[ "def", "simulate", "(", "self", ",", "program", ":", "Union", "[", "circuits", ".", "Circuit", ",", "schedules", ".", "Schedule", "]", ",", "param_resolver", ":", "'study.ParamResolverOrSimilarType'", "=", "None", ",", "qubit_order", ":", "ops", ".", "QubitOrd...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
SimulatesFinalState.simulate_sweep
Simulates the supplied Circuit or Schedule. This method returns a result which allows access to the entire wave function. In contrast to simulate, this allows for sweeping over different parameter values. Args: program: The circuit or schedule to simulate. param...
cirq/sim/simulator.py
def simulate_sweep( self, program: Union[circuits.Circuit, schedules.Schedule], params: study.Sweepable, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, initial_state: Any = None, ) -> List['SimulationTrialResult']: """Simulates the supplied Circuit or Sch...
def simulate_sweep( self, program: Union[circuits.Circuit, schedules.Schedule], params: study.Sweepable, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, initial_state: Any = None, ) -> List['SimulationTrialResult']: """Simulates the supplied Circuit or Sch...
[ "Simulates", "the", "supplied", "Circuit", "or", "Schedule", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/simulator.py#L214-L241
[ "def", "simulate_sweep", "(", "self", ",", "program", ":", "Union", "[", "circuits", ".", "Circuit", ",", "schedules", ".", "Schedule", "]", ",", "params", ":", "study", ".", "Sweepable", ",", "qubit_order", ":", "ops", ".", "QubitOrderOrList", "=", "ops",...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
SimulatesIntermediateState.simulate_sweep
Simulates the supplied Circuit or Schedule. This method returns a result which allows access to the entire wave function. In contrast to simulate, this allows for sweeping over different parameter values. Args: program: The circuit or schedule to simulate. param...
cirq/sim/simulator.py
def simulate_sweep( self, program: Union[circuits.Circuit, schedules.Schedule], params: study.Sweepable, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, initial_state: Any = None, ) -> List['SimulationTrialResult']: """Simulates the supplied Circuit or Sch...
def simulate_sweep( self, program: Union[circuits.Circuit, schedules.Schedule], params: study.Sweepable, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, initial_state: Any = None, ) -> List['SimulationTrialResult']: """Simulates the supplied Circuit or Sch...
[ "Simulates", "the", "supplied", "Circuit", "or", "Schedule", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/simulator.py#L255-L302
[ "def", "simulate_sweep", "(", "self", ",", "program", ":", "Union", "[", "circuits", ".", "Circuit", ",", "schedules", ".", "Schedule", "]", ",", "params", ":", "study", ".", "Sweepable", ",", "qubit_order", ":", "ops", ".", "QubitOrderOrList", "=", "ops",...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
SimulatesIntermediateState.simulate_moment_steps
Returns an iterator of StepResults for each moment simulated. If the circuit being simulated is empty, a single step result should be returned with the state being set to the initial state. Args: circuit: The Circuit to simulate. param_resolver: A ParamResolver for dete...
cirq/sim/simulator.py
def simulate_moment_steps( self, circuit: circuits.Circuit, param_resolver: 'study.ParamResolverOrSimilarType' = None, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, initial_state: Any = None ) -> Iterator: """Returns an iterator of StepResults for each m...
def simulate_moment_steps( self, circuit: circuits.Circuit, param_resolver: 'study.ParamResolverOrSimilarType' = None, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, initial_state: Any = None ) -> Iterator: """Returns an iterator of StepResults for each m...
[ "Returns", "an", "iterator", "of", "StepResults", "for", "each", "moment", "simulated", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/simulator.py#L304-L334
[ "def", "simulate_moment_steps", "(", "self", ",", "circuit", ":", "circuits", ".", "Circuit", ",", "param_resolver", ":", "'study.ParamResolverOrSimilarType'", "=", "None", ",", "qubit_order", ":", "ops", ".", "QubitOrderOrList", "=", "ops", ".", "QubitOrder", "."...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
SimulatesIntermediateState._simulator_iterator
Iterator over StepResult from Moments of a Circuit. Args: circuit: The circuit to simulate. param_resolver: A ParamResolver for determining values of Symbols. qubit_order: Determines the canonical ordering of the qubits. This is often used in ...
cirq/sim/simulator.py
def _simulator_iterator( self, circuit: circuits.Circuit, param_resolver: study.ParamResolver, qubit_order: ops.QubitOrderOrList, initial_state: Any, ) -> Iterator: """Iterator over StepResult from Moments of a Circuit. Args: circuit: The circuit ...
def _simulator_iterator( self, circuit: circuits.Circuit, param_resolver: study.ParamResolver, qubit_order: ops.QubitOrderOrList, initial_state: Any, ) -> Iterator: """Iterator over StepResult from Moments of a Circuit. Args: circuit: The circuit ...
[ "Iterator", "over", "StepResult", "from", "Moments", "of", "a", "Circuit", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/simulator.py#L337-L360
[ "def", "_simulator_iterator", "(", "self", ",", "circuit", ":", "circuits", ".", "Circuit", ",", "param_resolver", ":", "study", ".", "ParamResolver", ",", "qubit_order", ":", "ops", ".", "QubitOrderOrList", ",", "initial_state", ":", "Any", ",", ")", "->", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
SimulatesIntermediateState._create_simulator_trial_result
This method can be overridden to creation of a trial result. Args: params: The ParamResolver for this trial. measurements: The measurement results for this trial. final_simulator_state: The final state of the simulator for the StepResult. Returns: ...
cirq/sim/simulator.py
def _create_simulator_trial_result(self, params: study.ParamResolver, measurements: Dict[str, np.ndarray], final_simulator_state: Any) \ -> 'SimulationTrialResult': """This method can be overridden to creation of a trial result. Args: params: The ParamResolve...
def _create_simulator_trial_result(self, params: study.ParamResolver, measurements: Dict[str, np.ndarray], final_simulator_state: Any) \ -> 'SimulationTrialResult': """This method can be overridden to creation of a trial result. Args: params: The ParamResolve...
[ "This", "method", "can", "be", "overridden", "to", "creation", "of", "a", "trial", "result", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/simulator.py#L362-L381
[ "def", "_create_simulator_trial_result", "(", "self", ",", "params", ":", "study", ".", "ParamResolver", ",", "measurements", ":", "Dict", "[", "str", ",", "np", ".", "ndarray", "]", ",", "final_simulator_state", ":", "Any", ")", "->", "'SimulationTrialResult'",...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
StepResult.sample
Samples from the system at this point in the computation. Note that this does not collapse the wave function. Args: qubits: The qubits to be sampled in an order that influence the returned measurement results. repetitions: The number of samples to take. ...
cirq/sim/simulator.py
def sample(self, qubits: List[ops.Qid], repetitions: int = 1) -> np.ndarray: """Samples from the system at this point in the computation. Note that this does not collapse the wave function. Args: qubits: The qubits to be sampled in an order that influe...
def sample(self, qubits: List[ops.Qid], repetitions: int = 1) -> np.ndarray: """Samples from the system at this point in the computation. Note that this does not collapse the wave function. Args: qubits: The qubits to be sampled in an order that influe...
[ "Samples", "from", "the", "system", "at", "this", "point", "in", "the", "computation", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/simulator.py#L407-L425
[ "def", "sample", "(", "self", ",", "qubits", ":", "List", "[", "ops", ".", "Qid", "]", ",", "repetitions", ":", "int", "=", "1", ")", "->", "np", ".", "ndarray", ":", "raise", "NotImplementedError", "(", ")" ]
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
StepResult.sample_measurement_ops
Samples from the system at this point in the computation. Note that this does not collapse the wave function. In contrast to `sample` which samples qubits, this takes a list of `cirq.GateOperation` instances whose gates are `cirq.MeasurementGate` instances and then returns a mapping fr...
cirq/sim/simulator.py
def sample_measurement_ops( self, measurement_ops: List[ops.GateOperation], repetitions: int = 1) -> Dict[str, np.ndarray]: """Samples from the system at this point in the computation. Note that this does not collapse the wave function. In contrast to `sampl...
def sample_measurement_ops( self, measurement_ops: List[ops.GateOperation], repetitions: int = 1) -> Dict[str, np.ndarray]: """Samples from the system at this point in the computation. Note that this does not collapse the wave function. In contrast to `sampl...
[ "Samples", "from", "the", "system", "at", "this", "point", "in", "the", "computation", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/simulator.py#L427-L473
[ "def", "sample_measurement_ops", "(", "self", ",", "measurement_ops", ":", "List", "[", "ops", ".", "GateOperation", "]", ",", "repetitions", ":", "int", "=", "1", ")", "->", "Dict", "[", "str", ",", "np", ".", "ndarray", "]", ":", "bounds", "=", "{", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
xor_nonlocal_decompose
Decomposition ignores connectivity.
cirq/ops/pauli_string_phasor.py
def xor_nonlocal_decompose(qubits: Iterable[raw_types.Qid], onto_qubit: raw_types.Qid ) -> Iterable[raw_types.Operation]: """Decomposition ignores connectivity.""" for qubit in qubits: if qubit != onto_qubit: yield common_gates.CNOT(qubit,...
def xor_nonlocal_decompose(qubits: Iterable[raw_types.Qid], onto_qubit: raw_types.Qid ) -> Iterable[raw_types.Operation]: """Decomposition ignores connectivity.""" for qubit in qubits: if qubit != onto_qubit: yield common_gates.CNOT(qubit,...
[ "Decomposition", "ignores", "connectivity", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/pauli_string_phasor.py#L174-L180
[ "def", "xor_nonlocal_decompose", "(", "qubits", ":", "Iterable", "[", "raw_types", ".", "Qid", "]", ",", "onto_qubit", ":", "raw_types", ".", "Qid", ")", "->", "Iterable", "[", "raw_types", ".", "Operation", "]", ":", "for", "qubit", "in", "qubits", ":", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
proper_repr
Overrides sympy and numpy returning repr strings that don't parse.
cirq/_compat.py
def proper_repr(value: Any) -> str: """Overrides sympy and numpy returning repr strings that don't parse.""" if isinstance(value, sympy.Basic): result = sympy.srepr(value) # HACK: work around https://github.com/sympy/sympy/issues/16074 # (only handles a few cases) fixed_tokens ...
def proper_repr(value: Any) -> str: """Overrides sympy and numpy returning repr strings that don't parse.""" if isinstance(value, sympy.Basic): result = sympy.srepr(value) # HACK: work around https://github.com/sympy/sympy/issues/16074 # (only handles a few cases) fixed_tokens ...
[ "Overrides", "sympy", "and", "numpy", "returning", "repr", "strings", "that", "don", "t", "parse", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/_compat.py#L22-L40
[ "def", "proper_repr", "(", "value", ":", "Any", ")", "->", "str", ":", "if", "isinstance", "(", "value", ",", "sympy", ".", "Basic", ")", ":", "result", "=", "sympy", ".", "srepr", "(", "value", ")", "# HACK: work around https://github.com/sympy/sympy/issues/1...
0827da80dd7880e5b923eb69407e980ed9bc0bd2