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 | GPMC._build_likelihood | r"""
Construct a tf function to compute the likelihood of a general GP
model.
\log p(Y, V | theta). | gpflow/models/gpmc.py | def _build_likelihood(self):
r"""
Construct a tf function to compute the likelihood of a general GP
model.
\log p(Y, V | theta).
"""
K = self.kern.K(self.X)
L = tf.cholesky(
K + tf.eye(tf.shape(self.X)[0], dtype=settings.float_type) * settings.nu... | def _build_likelihood(self):
r"""
Construct a tf function to compute the likelihood of a general GP
model.
\log p(Y, V | theta).
"""
K = self.kern.K(self.X)
L = tf.cholesky(
K + tf.eye(tf.shape(self.X)[0], dtype=settings.float_type) * settings.nu... | [
"r",
"Construct",
"a",
"tf",
"function",
"to",
"compute",
"the",
"likelihood",
"of",
"a",
"general",
"GP",
"model",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/gpmc.py#L73-L86 | [
"def",
"_build_likelihood",
"(",
"self",
")",
":",
"K",
"=",
"self",
".",
"kern",
".",
"K",
"(",
"self",
".",
"X",
")",
"L",
"=",
"tf",
".",
"cholesky",
"(",
"K",
"+",
"tf",
".",
"eye",
"(",
"tf",
".",
"shape",
"(",
"self",
".",
"X",
")",
"... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | GPMC._build_predict | Xnew is a data matrix, point at which we want to predict
This method computes
p(F* | (F=LV) )
where F* are points on the GP at Xnew, F=LV are points on the GP at X. | gpflow/models/gpmc.py | def _build_predict(self, Xnew, full_cov=False):
"""
Xnew is a data matrix, point at which we want to predict
This method computes
p(F* | (F=LV) )
where F* are points on the GP at Xnew, F=LV are points on the GP at X.
"""
mu, var = conditional(Xnew, self.X,... | def _build_predict(self, Xnew, full_cov=False):
"""
Xnew is a data matrix, point at which we want to predict
This method computes
p(F* | (F=LV) )
where F* are points on the GP at Xnew, F=LV are points on the GP at X.
"""
mu, var = conditional(Xnew, self.X,... | [
"Xnew",
"is",
"a",
"data",
"matrix",
"point",
"at",
"which",
"we",
"want",
"to",
"predict"
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/gpmc.py#L89-L103 | [
"def",
"_build_predict",
"(",
"self",
",",
"Xnew",
",",
"full_cov",
"=",
"False",
")",
":",
"mu",
",",
"var",
"=",
"conditional",
"(",
"Xnew",
",",
"self",
".",
"X",
",",
"self",
".",
"kern",
",",
"self",
".",
"V",
",",
"full_cov",
"=",
"full_cov",... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | SVGP._init_variational_parameters | Constructs the mean and cholesky of the covariance of the variational Gaussian posterior.
If a user passes values for `q_mu` and `q_sqrt` the routine checks if they have consistent
and correct shapes. If a user does not specify any values for `q_mu` and `q_sqrt`, the routine
initializes them, th... | gpflow/models/svgp.py | def _init_variational_parameters(self, num_inducing, q_mu, q_sqrt, q_diag):
"""
Constructs the mean and cholesky of the covariance of the variational Gaussian posterior.
If a user passes values for `q_mu` and `q_sqrt` the routine checks if they have consistent
and correct shapes. If a us... | def _init_variational_parameters(self, num_inducing, q_mu, q_sqrt, q_diag):
"""
Constructs the mean and cholesky of the covariance of the variational Gaussian posterior.
If a user passes values for `q_mu` and `q_sqrt` the routine checks if they have consistent
and correct shapes. If a us... | [
"Constructs",
"the",
"mean",
"and",
"cholesky",
"of",
"the",
"covariance",
"of",
"the",
"variational",
"Gaussian",
"posterior",
".",
"If",
"a",
"user",
"passes",
"values",
"for",
"q_mu",
"and",
"q_sqrt",
"the",
"routine",
"checks",
"if",
"they",
"have",
"con... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/svgp.py#L90-L137 | [
"def",
"_init_variational_parameters",
"(",
"self",
",",
"num_inducing",
",",
"q_mu",
",",
"q_sqrt",
",",
"q_diag",
")",
":",
"q_mu",
"=",
"np",
".",
"zeros",
"(",
"(",
"num_inducing",
",",
"self",
".",
"num_latent",
")",
")",
"if",
"q_mu",
"is",
"None",... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | SVGP._build_likelihood | This gives a variational bound on the model likelihood. | gpflow/models/svgp.py | def _build_likelihood(self):
"""
This gives a variational bound on the model likelihood.
"""
# Get prior KL.
KL = self.build_prior_KL()
# Get conditionals
fmean, fvar = self._build_predict(self.X, full_cov=False, full_output_cov=False)
# Get variational... | def _build_likelihood(self):
"""
This gives a variational bound on the model likelihood.
"""
# Get prior KL.
KL = self.build_prior_KL()
# Get conditionals
fmean, fvar = self._build_predict(self.X, full_cov=False, full_output_cov=False)
# Get variational... | [
"This",
"gives",
"a",
"variational",
"bound",
"on",
"the",
"model",
"likelihood",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/svgp.py#L149-L166 | [
"def",
"_build_likelihood",
"(",
"self",
")",
":",
"# Get prior KL.",
"KL",
"=",
"self",
".",
"build_prior_KL",
"(",
")",
"# Get conditionals",
"fmean",
",",
"fvar",
"=",
"self",
".",
"_build_predict",
"(",
"self",
".",
"X",
",",
"full_cov",
"=",
"False",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Node.compile | Compile is two phase operation: at first it calls `build` method and then
intializes the node for passed session. The policy around `session` is defined
inside the `initialize` method.
:param session: TensorFlow session used for initializing. If the node is built the
session's graph... | gpflow/core/node.py | def compile(self, session=None):
"""
Compile is two phase operation: at first it calls `build` method and then
intializes the node for passed session. The policy around `session` is defined
inside the `initialize` method.
:param session: TensorFlow session used for initializing.... | def compile(self, session=None):
"""
Compile is two phase operation: at first it calls `build` method and then
intializes the node for passed session. The policy around `session` is defined
inside the `initialize` method.
:param session: TensorFlow session used for initializing.... | [
"Compile",
"is",
"two",
"phase",
"operation",
":",
"at",
"first",
"it",
"calls",
"build",
"method",
"and",
"then",
"intializes",
"the",
"node",
"for",
"passed",
"session",
".",
"The",
"policy",
"around",
"session",
"is",
"defined",
"inside",
"the",
"initiali... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/node.py#L43-L59 | [
"def",
"compile",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"session",
"=",
"self",
".",
"enquire_session",
"(",
"session",
")",
"if",
"self",
".",
"is_built_coherence",
"(",
"session",
".",
"graph",
")",
"is",
"Build",
".",
"NO",
":",
"with"... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Node.initialize | Initializes TensorFlow variables, which are returned by `initializables` property and
uses feed dictionary returned by `initializable_feeds` property defined at ICompilable
interface and implemented by descendants.
:param session: TensorFlow session used for initializing. In case when session i... | gpflow/core/node.py | def initialize(self, session=None, force=False):
"""
Initializes TensorFlow variables, which are returned by `initializables` property and
uses feed dictionary returned by `initializable_feeds` property defined at ICompilable
interface and implemented by descendants.
:param sess... | def initialize(self, session=None, force=False):
"""
Initializes TensorFlow variables, which are returned by `initializables` property and
uses feed dictionary returned by `initializable_feeds` property defined at ICompilable
interface and implemented by descendants.
:param sess... | [
"Initializes",
"TensorFlow",
"variables",
"which",
"are",
"returned",
"by",
"initializables",
"property",
"and",
"uses",
"feed",
"dictionary",
"returned",
"by",
"initializable_feeds",
"property",
"defined",
"at",
"ICompilable",
"interface",
"and",
"implemented",
"by",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/node.py#L61-L84 | [
"def",
"initialize",
"(",
"self",
",",
"session",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"session",
"=",
"self",
".",
"enquire_session",
"(",
"session",
")",
"initializables",
"=",
"self",
".",
"initializables",
"if",
"initializables",
":",
"mi... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Node.clear | Calls `_clear` abstract method which must be implemented by descendants.
:raises: GPflowError exception when parent of the node is built. | gpflow/core/node.py | def clear(self):
"""
Calls `_clear` abstract method which must be implemented by descendants.
:raises: GPflowError exception when parent of the node is built.
"""
parent = self.parent
if parent is not self and parent.is_built_coherence(self.graph) is Build.YES:
... | def clear(self):
"""
Calls `_clear` abstract method which must be implemented by descendants.
:raises: GPflowError exception when parent of the node is built.
"""
parent = self.parent
if parent is not self and parent.is_built_coherence(self.graph) is Build.YES:
... | [
"Calls",
"_clear",
"abstract",
"method",
"which",
"must",
"be",
"implemented",
"by",
"descendants",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/node.py#L86-L95 | [
"def",
"clear",
"(",
"self",
")",
":",
"parent",
"=",
"self",
".",
"parent",
"if",
"parent",
"is",
"not",
"self",
"and",
"parent",
".",
"is_built_coherence",
"(",
"self",
".",
"graph",
")",
"is",
"Build",
".",
"YES",
":",
"raise",
"GPflowError",
"(",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Node.enquire_graph | Verifies and returns relevant TensorFlow graph. If non-None graph were passed,
the same graph is returned. Otherwise, nodes's graph is exposed and it is
undefined the default TensorFlow graph is used.
:param graph: TensorFlow graph or None. Default is None.
:return: TensorFlow graph. | gpflow/core/node.py | def enquire_graph(self, graph=None):
"""
Verifies and returns relevant TensorFlow graph. If non-None graph were passed,
the same graph is returned. Otherwise, nodes's graph is exposed and it is
undefined the default TensorFlow graph is used.
:param graph: TensorFlow graph or Non... | def enquire_graph(self, graph=None):
"""
Verifies and returns relevant TensorFlow graph. If non-None graph were passed,
the same graph is returned. Otherwise, nodes's graph is exposed and it is
undefined the default TensorFlow graph is used.
:param graph: TensorFlow graph or Non... | [
"Verifies",
"and",
"returns",
"relevant",
"TensorFlow",
"graph",
".",
"If",
"non",
"-",
"None",
"graph",
"were",
"passed",
"the",
"same",
"graph",
"is",
"returned",
".",
"Otherwise",
"nodes",
"s",
"graph",
"is",
"exposed",
"and",
"it",
"is",
"undefined",
"... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/node.py#L97-L110 | [
"def",
"enquire_graph",
"(",
"self",
",",
"graph",
"=",
"None",
")",
":",
"if",
"graph",
"is",
"None",
":",
"graph",
"=",
"self",
".",
"root",
".",
"graph",
"if",
"self",
".",
"graph",
"is",
"None",
"else",
"self",
".",
"graph",
"if",
"graph",
"is"... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Node.enquire_session | Verifies and returns relevant TensorFlow session. If non-None session
were passed, session is checked for graph compliance and returned back.
Otherwise, default TensorFlow session is returned. When TensorFlow default
session is not set up, GPflow session's manager creates or uses existing
... | gpflow/core/node.py | def enquire_session(self, session=None):
"""
Verifies and returns relevant TensorFlow session. If non-None session
were passed, session is checked for graph compliance and returned back.
Otherwise, default TensorFlow session is returned. When TensorFlow default
session is not set... | def enquire_session(self, session=None):
"""
Verifies and returns relevant TensorFlow session. If non-None session
were passed, session is checked for graph compliance and returned back.
Otherwise, default TensorFlow session is returned. When TensorFlow default
session is not set... | [
"Verifies",
"and",
"returns",
"relevant",
"TensorFlow",
"session",
".",
"If",
"non",
"-",
"None",
"session",
"were",
"passed",
"session",
"is",
"checked",
"for",
"graph",
"compliance",
"and",
"returned",
"back",
".",
"Otherwise",
"default",
"TensorFlow",
"sessio... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/node.py#L112-L129 | [
"def",
"enquire_session",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"if",
"session",
"is",
"None",
":",
"session",
"=",
"tf",
".",
"get_default_session",
"(",
")",
"if",
"session",
"is",
"None",
":",
"session",
"=",
"session_manager",
".",
"get... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Node.is_built_coherence | Checks that node was build using input `graph`.
:return: `Build` status.
:raises GPflowError: Valid passed TensorFlow graph is different from
used graph in node. | gpflow/core/node.py | def is_built_coherence(self, graph=None):
"""
Checks that node was build using input `graph`.
:return: `Build` status.
:raises GPflowError: Valid passed TensorFlow graph is different from
used graph in node.
"""
graph = self.enquire_graph(graph=graph)
... | def is_built_coherence(self, graph=None):
"""
Checks that node was build using input `graph`.
:return: `Build` status.
:raises GPflowError: Valid passed TensorFlow graph is different from
used graph in node.
"""
graph = self.enquire_graph(graph=graph)
... | [
"Checks",
"that",
"node",
"was",
"build",
"using",
"input",
"graph",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/node.py#L131-L143 | [
"def",
"is_built_coherence",
"(",
"self",
",",
"graph",
"=",
"None",
")",
":",
"graph",
"=",
"self",
".",
"enquire_graph",
"(",
"graph",
"=",
"graph",
")",
"is_built",
"=",
"self",
".",
"is_built",
"(",
"graph",
")",
"if",
"is_built",
"is",
"Build",
".... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Node.build | Implementation for ICompilable interface `build` method. Builds tensors within
TensorFlow name scope using parentable node's name. Hidden name is used when
no parent exists for current node.
:raises GPflowError: Node's parts were built with different graph and differ from
default T... | gpflow/core/node.py | def build(self):
"""
Implementation for ICompilable interface `build` method. Builds tensors within
TensorFlow name scope using parentable node's name. Hidden name is used when
no parent exists for current node.
:raises GPflowError: Node's parts were built with different graph ... | def build(self):
"""
Implementation for ICompilable interface `build` method. Builds tensors within
TensorFlow name scope using parentable node's name. Hidden name is used when
no parent exists for current node.
:raises GPflowError: Node's parts were built with different graph ... | [
"Implementation",
"for",
"ICompilable",
"interface",
"build",
"method",
".",
"Builds",
"tensors",
"within",
"TensorFlow",
"name",
"scope",
"using",
"parentable",
"node",
"s",
"name",
".",
"Hidden",
"name",
"is",
"used",
"when",
"no",
"parent",
"exists",
"for",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/node.py#L145-L156 | [
"def",
"build",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_built_coherence",
"(",
")",
"is",
"Build",
".",
"NO",
":",
"with",
"tf",
".",
"name_scope",
"(",
"self",
".",
"tf_name_scope",
")",
":",
"self",
".",
"_build",
"(",
")"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Node.tf_name_scope | Auxilary method for composing gpflow's tree name scopes. The Parentable pathname
can be considered as a set of name scopes. This method grabs `pathname` and
returns only name of the node in that path.
Leading node name is always replaced with two parts: the name and the index
for uniquin... | gpflow/core/node.py | def tf_name_scope(self):
"""
Auxilary method for composing gpflow's tree name scopes. The Parentable pathname
can be considered as a set of name scopes. This method grabs `pathname` and
returns only name of the node in that path.
Leading node name is always replaced with two part... | def tf_name_scope(self):
"""
Auxilary method for composing gpflow's tree name scopes. The Parentable pathname
can be considered as a set of name scopes. This method grabs `pathname` and
returns only name of the node in that path.
Leading node name is always replaced with two part... | [
"Auxilary",
"method",
"for",
"composing",
"gpflow",
"s",
"tree",
"name",
"scopes",
".",
"The",
"Parentable",
"pathname",
"can",
"be",
"considered",
"as",
"a",
"set",
"of",
"name",
"scopes",
".",
"This",
"method",
"grabs",
"pathname",
"and",
"returns",
"only"... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/node.py#L159-L173 | [
"def",
"tf_name_scope",
"(",
"self",
")",
":",
"if",
"self",
".",
"parent",
"is",
"self",
":",
"leader_name",
"=",
"self",
".",
"name",
"leader_index",
"=",
"self",
".",
"index",
"if",
"leader_index",
"is",
"None",
":",
"return",
"leader_name",
"return",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Node.tf_pathname | Method used for defining full path name for particular tensor at build time.
For example, `tf.get_variable` creates variable w/o taking into account
name scopes and `tf_pathname` consists of all parts of scope names
which were used up to that point - `tf.get_variable` call. | gpflow/core/node.py | def tf_pathname(self):
"""
Method used for defining full path name for particular tensor at build time.
For example, `tf.get_variable` creates variable w/o taking into account
name scopes and `tf_pathname` consists of all parts of scope names
which were used up to that point - `t... | def tf_pathname(self):
"""
Method used for defining full path name for particular tensor at build time.
For example, `tf.get_variable` creates variable w/o taking into account
name scopes and `tf_pathname` consists of all parts of scope names
which were used up to that point - `t... | [
"Method",
"used",
"for",
"defining",
"full",
"path",
"name",
"for",
"particular",
"tensor",
"at",
"build",
"time",
".",
"For",
"example",
"tf",
".",
"get_variable",
"creates",
"variable",
"w",
"/",
"o",
"taking",
"into",
"account",
"name",
"scopes",
"and",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/node.py#L176-L187 | [
"def",
"tf_pathname",
"(",
"self",
")",
":",
"if",
"self",
".",
"parent",
"is",
"self",
":",
"return",
"self",
".",
"tf_name_scope",
"tail",
"=",
"self",
".",
"pathname",
".",
"split",
"(",
"'/'",
",",
"1",
")",
"[",
"-",
"1",
"]",
"leader",
"=",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | autobuild_decorate | autobuild_decorate(func, caller) decorates a function using a caller.
Allows for an extra `autobuild` keyword arg.
The only difference to decorator.decorate() is to use our custom AutobuildFunctionMaker instead. | gpflow/core/compilable.py | def autobuild_decorate(func, caller):
"""
autobuild_decorate(func, caller) decorates a function using a caller.
Allows for an extra `autobuild` keyword arg.
The only difference to decorator.decorate() is to use our custom AutobuildFunctionMaker instead.
"""
evaldict = dict(_call_=caller, _func_=... | def autobuild_decorate(func, caller):
"""
autobuild_decorate(func, caller) decorates a function using a caller.
Allows for an extra `autobuild` keyword arg.
The only difference to decorator.decorate() is to use our custom AutobuildFunctionMaker instead.
"""
evaldict = dict(_call_=caller, _func_=... | [
"autobuild_decorate",
"(",
"func",
"caller",
")",
"decorates",
"a",
"function",
"using",
"a",
"caller",
".",
"Allows",
"for",
"an",
"extra",
"autobuild",
"keyword",
"arg",
".",
"The",
"only",
"difference",
"to",
"decorator",
".",
"decorate",
"()",
"is",
"to"... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/compilable.py#L84-L96 | [
"def",
"autobuild_decorate",
"(",
"func",
",",
"caller",
")",
":",
"evaldict",
"=",
"dict",
"(",
"_call_",
"=",
"caller",
",",
"_func_",
"=",
"func",
")",
"fun",
"=",
"AutobuildFunctionMaker",
".",
"create",
"(",
"func",
",",
"\"return _call_(_func_, %(shortsi... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Parameterized._build_prior | Build a tf expression for the prior by summing all child-parameter priors. | gpflow/params/parameterized.py | def _build_prior(self, prior_tensors):
"""
Build a tf expression for the prior by summing all child-parameter priors.
"""
# TODO(@awav): What prior must represent empty list of parameters?
if not prior_tensors:
return tf.constant(0, dtype=settings.float_type)
... | def _build_prior(self, prior_tensors):
"""
Build a tf expression for the prior by summing all child-parameter priors.
"""
# TODO(@awav): What prior must represent empty list of parameters?
if not prior_tensors:
return tf.constant(0, dtype=settings.float_type)
... | [
"Build",
"a",
"tf",
"expression",
"for",
"the",
"prior",
"by",
"summing",
"all",
"child",
"-",
"parameter",
"priors",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/params/parameterized.py#L304-L311 | [
"def",
"_build_prior",
"(",
"self",
",",
"prior_tensors",
")",
":",
"# TODO(@awav): What prior must represent empty list of parameters?",
"if",
"not",
"prior_tensors",
":",
"return",
"tf",
".",
"constant",
"(",
"0",
",",
"dtype",
"=",
"settings",
".",
"float_type",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | _broadcasting_elementwise_op | r"""
Apply binary operation `op` to every pair in tensors `a` and `b`.
:param op: binary operator on tensors, e.g. tf.add, tf.substract
:param a: tf.Tensor, shape [n_1, ..., n_a]
:param b: tf.Tensor, shape [m_1, ..., m_b]
:return: tf.Tensor, shape [n_1, ..., n_a, m_1, ..., m_b] | gpflow/kernels.py | def _broadcasting_elementwise_op(op, a, b):
r"""
Apply binary operation `op` to every pair in tensors `a` and `b`.
:param op: binary operator on tensors, e.g. tf.add, tf.substract
:param a: tf.Tensor, shape [n_1, ..., n_a]
:param b: tf.Tensor, shape [m_1, ..., m_b]
:return: tf.Tensor, shape [n_1... | def _broadcasting_elementwise_op(op, a, b):
r"""
Apply binary operation `op` to every pair in tensors `a` and `b`.
:param op: binary operator on tensors, e.g. tf.add, tf.substract
:param a: tf.Tensor, shape [n_1, ..., n_a]
:param b: tf.Tensor, shape [m_1, ..., m_b]
:return: tf.Tensor, shape [n_1... | [
"r",
"Apply",
"binary",
"operation",
"op",
"to",
"every",
"pair",
"in",
"tensors",
"a",
"and",
"b",
".",
":",
"param",
"op",
":",
"binary",
"operator",
"on",
"tensors",
"e",
".",
"g",
".",
"tf",
".",
"add",
"tf",
".",
"substract",
":",
"param",
"a"... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/kernels.py#L846-L855 | [
"def",
"_broadcasting_elementwise_op",
"(",
"op",
",",
"a",
",",
"b",
")",
":",
"flatres",
"=",
"op",
"(",
"tf",
".",
"reshape",
"(",
"a",
",",
"[",
"-",
"1",
",",
"1",
"]",
")",
",",
"tf",
".",
"reshape",
"(",
"b",
",",
"[",
"1",
",",
"-",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | make_deprecated_class | Returns a class that raises NotImplementedError on instantiation.
e.g.:
>>> Kern = make_deprecated_class("Kern", Kernel) | gpflow/kernels.py | def make_deprecated_class(oldname, NewClass):
"""
Returns a class that raises NotImplementedError on instantiation.
e.g.:
>>> Kern = make_deprecated_class("Kern", Kernel)
"""
msg = ("{module}.{} has been renamed to {module}.{}"
.format(oldname, NewClass.__name__, module=NewClass.__mod... | def make_deprecated_class(oldname, NewClass):
"""
Returns a class that raises NotImplementedError on instantiation.
e.g.:
>>> Kern = make_deprecated_class("Kern", Kernel)
"""
msg = ("{module}.{} has been renamed to {module}.{}"
.format(oldname, NewClass.__name__, module=NewClass.__mod... | [
"Returns",
"a",
"class",
"that",
"raises",
"NotImplementedError",
"on",
"instantiation",
".",
"e",
".",
"g",
".",
":",
">>>",
"Kern",
"=",
"make_deprecated_class",
"(",
"Kern",
"Kernel",
")"
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/kernels.py#L858-L872 | [
"def",
"make_deprecated_class",
"(",
"oldname",
",",
"NewClass",
")",
":",
"msg",
"=",
"(",
"\"{module}.{} has been renamed to {module}.{}\"",
".",
"format",
"(",
"oldname",
",",
"NewClass",
".",
"__name__",
",",
"module",
"=",
"NewClass",
".",
"__module__",
")",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Kernel._validate_ard_shape | Validates the shape of a potentially ARD hyperparameter
:param name: The name of the parameter (used for error messages)
:param value: A scalar or an array.
:param ARD: None, False, or True. If None, infers ARD from shape of value.
:return: Tuple (value, ARD), where _value_ is a scalar ... | gpflow/kernels.py | def _validate_ard_shape(self, name, value, ARD=None):
"""
Validates the shape of a potentially ARD hyperparameter
:param name: The name of the parameter (used for error messages)
:param value: A scalar or an array.
:param ARD: None, False, or True. If None, infers ARD from shape... | def _validate_ard_shape(self, name, value, ARD=None):
"""
Validates the shape of a potentially ARD hyperparameter
:param name: The name of the parameter (used for error messages)
:param value: A scalar or an array.
:param ARD: None, False, or True. If None, infers ARD from shape... | [
"Validates",
"the",
"shape",
"of",
"a",
"potentially",
"ARD",
"hyperparameter"
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/kernels.py#L68-L93 | [
"def",
"_validate_ard_shape",
"(",
"self",
",",
"name",
",",
"value",
",",
"ARD",
"=",
"None",
")",
":",
"if",
"ARD",
"is",
"None",
":",
"ARD",
"=",
"np",
".",
"asarray",
"(",
"value",
")",
".",
"squeeze",
"(",
")",
".",
"shape",
"!=",
"(",
")",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Kernel.on_separate_dims | Checks if the dimensions, over which the kernels are specified, overlap.
Returns True if they are defined on different/separate dimensions and False otherwise. | gpflow/kernels.py | def on_separate_dims(self, other_kernel):
"""
Checks if the dimensions, over which the kernels are specified, overlap.
Returns True if they are defined on different/separate dimensions and False otherwise.
"""
if isinstance(self.active_dims, slice) or isinstance(other_kernel.acti... | def on_separate_dims(self, other_kernel):
"""
Checks if the dimensions, over which the kernels are specified, overlap.
Returns True if they are defined on different/separate dimensions and False otherwise.
"""
if isinstance(self.active_dims, slice) or isinstance(other_kernel.acti... | [
"Checks",
"if",
"the",
"dimensions",
"over",
"which",
"the",
"kernels",
"are",
"specified",
"overlap",
".",
"Returns",
"True",
"if",
"they",
"are",
"defined",
"on",
"different",
"/",
"separate",
"dimensions",
"and",
"False",
"otherwise",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/kernels.py#L108-L120 | [
"def",
"on_separate_dims",
"(",
"self",
",",
"other_kernel",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"active_dims",
",",
"slice",
")",
"or",
"isinstance",
"(",
"other_kernel",
".",
"active_dims",
",",
"slice",
")",
":",
"# Be very conservative for kernel... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Kernel._slice | Slice the correct dimensions for use in the kernel, as indicated by
`self.active_dims`.
:param X: Input 1 (NxD).
:param X2: Input 2 (MxD), may be None.
:return: Sliced X, X2, (Nxself.input_dim). | gpflow/kernels.py | def _slice(self, X, X2):
"""
Slice the correct dimensions for use in the kernel, as indicated by
`self.active_dims`.
:param X: Input 1 (NxD).
:param X2: Input 2 (MxD), may be None.
:return: Sliced X, X2, (Nxself.input_dim).
"""
if isinstance(self.active_di... | def _slice(self, X, X2):
"""
Slice the correct dimensions for use in the kernel, as indicated by
`self.active_dims`.
:param X: Input 1 (NxD).
:param X2: Input 2 (MxD), may be None.
:return: Sliced X, X2, (Nxself.input_dim).
"""
if isinstance(self.active_di... | [
"Slice",
"the",
"correct",
"dimensions",
"for",
"use",
"in",
"the",
"kernel",
"as",
"indicated",
"by",
"self",
".",
"active_dims",
".",
":",
"param",
"X",
":",
"Input",
"1",
"(",
"NxD",
")",
".",
":",
"param",
"X2",
":",
"Input",
"2",
"(",
"MxD",
"... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/kernels.py#L122-L144 | [
"def",
"_slice",
"(",
"self",
",",
"X",
",",
"X2",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"active_dims",
",",
"slice",
")",
":",
"X",
"=",
"X",
"[",
"...",
",",
"self",
".",
"active_dims",
"]",
"if",
"X2",
"is",
"not",
"None",
":",
"X2... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Kernel._slice_cov | Slice the correct dimensions for use in the kernel, as indicated by
`self.active_dims` for covariance matrices. This requires slicing the
rows *and* columns. This will also turn flattened diagonal
matrices into a tensor of full diagonal matrices.
:param cov: Tensor of covariance matrices... | gpflow/kernels.py | def _slice_cov(self, cov):
"""
Slice the correct dimensions for use in the kernel, as indicated by
`self.active_dims` for covariance matrices. This requires slicing the
rows *and* columns. This will also turn flattened diagonal
matrices into a tensor of full diagonal matrices.
... | def _slice_cov(self, cov):
"""
Slice the correct dimensions for use in the kernel, as indicated by
`self.active_dims` for covariance matrices. This requires slicing the
rows *and* columns. This will also turn flattened diagonal
matrices into a tensor of full diagonal matrices.
... | [
"Slice",
"the",
"correct",
"dimensions",
"for",
"use",
"in",
"the",
"kernel",
"as",
"indicated",
"by",
"self",
".",
"active_dims",
"for",
"covariance",
"matrices",
".",
"This",
"requires",
"slicing",
"the",
"rows",
"*",
"and",
"*",
"columns",
".",
"This",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/kernels.py#L146-L166 | [
"def",
"_slice_cov",
"(",
"self",
",",
"cov",
")",
":",
"cov",
"=",
"tf",
".",
"cond",
"(",
"tf",
".",
"equal",
"(",
"tf",
".",
"rank",
"(",
"cov",
")",
",",
"2",
")",
",",
"lambda",
":",
"tf",
".",
"matrix_diag",
"(",
"cov",
")",
",",
"lambd... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Stationary._scaled_square_dist | Returns ((X - X2ᵀ)/lengthscales)².
Due to the implementation and floating-point imprecision, the
result may actually be very slightly negative for entries very
close to each other.
This function can deal with leading dimensions in X and X2.
In the sample case, where X and X2 ar... | gpflow/kernels.py | def _scaled_square_dist(self, X, X2):
"""
Returns ((X - X2ᵀ)/lengthscales)².
Due to the implementation and floating-point imprecision, the
result may actually be very slightly negative for entries very
close to each other.
This function can deal with leading dimensions i... | def _scaled_square_dist(self, X, X2):
"""
Returns ((X - X2ᵀ)/lengthscales)².
Due to the implementation and floating-point imprecision, the
result may actually be very slightly negative for entries very
close to each other.
This function can deal with leading dimensions i... | [
"Returns",
"((",
"X",
"-",
"X2ᵀ",
")",
"/",
"lengthscales",
")",
"²",
".",
"Due",
"to",
"the",
"implementation",
"and",
"floating",
"-",
"point",
"imprecision",
"the",
"result",
"may",
"actually",
"be",
"very",
"slightly",
"negative",
"for",
"entries",
"ve... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/kernels.py#L275-L302 | [
"def",
"_scaled_square_dist",
"(",
"self",
",",
"X",
",",
"X2",
")",
":",
"X",
"=",
"X",
"/",
"self",
".",
"lengthscales",
"if",
"X2",
"is",
"None",
":",
"Xs",
"=",
"tf",
".",
"reduce_sum",
"(",
"tf",
".",
"square",
"(",
"X",
")",
",",
"axis",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Stationary.scaled_euclid_dist | Returns |(X - X2ᵀ)/lengthscales| (L2-norm). | gpflow/kernels.py | def scaled_euclid_dist(self, X, X2): # pragma: no cover
"""
Returns |(X - X2ᵀ)/lengthscales| (L2-norm).
"""
warnings.warn('scaled_euclid_dist is deprecated and will be removed '
'in GPflow version 1.4.0. For stationary kernels, '
'define K_r(r... | def scaled_euclid_dist(self, X, X2): # pragma: no cover
"""
Returns |(X - X2ᵀ)/lengthscales| (L2-norm).
"""
warnings.warn('scaled_euclid_dist is deprecated and will be removed '
'in GPflow version 1.4.0. For stationary kernels, '
'define K_r(r... | [
"Returns",
"|",
"(",
"X",
"-",
"X2ᵀ",
")",
"/",
"lengthscales|",
"(",
"L2",
"-",
"norm",
")",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/kernels.py#L313-L322 | [
"def",
"scaled_euclid_dist",
"(",
"self",
",",
"X",
",",
"X2",
")",
":",
"# pragma: no cover",
"warnings",
".",
"warn",
"(",
"'scaled_euclid_dist is deprecated and will be removed '",
"'in GPflow version 1.4.0. For stationary kernels, '",
"'define K_r(r) instead.'",
",",
"Depre... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Stationary.K | Calculates the kernel matrix K(X, X2) (or K(X, X) if X2 is None).
Handles the slicing as well as scaling and computes k(x, x') = k(r),
where r² = ((x - x')/lengthscales)².
Internally, this calls self.K_r2(r²), which in turn computes the
square-root and calls self.K_r(r). Classes impleme... | gpflow/kernels.py | def K(self, X, X2=None, presliced=False):
"""
Calculates the kernel matrix K(X, X2) (or K(X, X) if X2 is None).
Handles the slicing as well as scaling and computes k(x, x') = k(r),
where r² = ((x - x')/lengthscales)².
Internally, this calls self.K_r2(r²), which in turn computes ... | def K(self, X, X2=None, presliced=False):
"""
Calculates the kernel matrix K(X, X2) (or K(X, X) if X2 is None).
Handles the slicing as well as scaling and computes k(x, x') = k(r),
where r² = ((x - x')/lengthscales)².
Internally, this calls self.K_r2(r²), which in turn computes ... | [
"Calculates",
"the",
"kernel",
"matrix",
"K",
"(",
"X",
"X2",
")",
"(",
"or",
"K",
"(",
"X",
"X",
")",
"if",
"X2",
"is",
"None",
")",
".",
"Handles",
"the",
"slicing",
"as",
"well",
"as",
"scaling",
"and",
"computes",
"k",
"(",
"x",
"x",
")",
"... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/kernels.py#L330-L343 | [
"def",
"K",
"(",
"self",
",",
"X",
",",
"X2",
"=",
"None",
",",
"presliced",
"=",
"False",
")",
":",
"if",
"not",
"presliced",
":",
"X",
",",
"X2",
"=",
"self",
".",
"_slice",
"(",
"X",
",",
"X2",
")",
"return",
"self",
".",
"K_r2",
"(",
"sel... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Stationary.K_r2 | Returns the kernel evaluated on `r2`, which is the scaled squared distance.
Will call self.K_r(r=sqrt(r2)), or can be overwritten directly (and should operate element-wise on r2). | gpflow/kernels.py | def K_r2(self, r2):
"""
Returns the kernel evaluated on `r2`, which is the scaled squared distance.
Will call self.K_r(r=sqrt(r2)), or can be overwritten directly (and should operate element-wise on r2).
"""
r = self._clipped_sqrt(r2)
return self.K_r(r) | def K_r2(self, r2):
"""
Returns the kernel evaluated on `r2`, which is the scaled squared distance.
Will call self.K_r(r=sqrt(r2)), or can be overwritten directly (and should operate element-wise on r2).
"""
r = self._clipped_sqrt(r2)
return self.K_r(r) | [
"Returns",
"the",
"kernel",
"evaluated",
"on",
"r2",
"which",
"is",
"the",
"scaled",
"squared",
"distance",
".",
"Will",
"call",
"self",
".",
"K_r",
"(",
"r",
"=",
"sqrt",
"(",
"r2",
"))",
"or",
"can",
"be",
"overwritten",
"directly",
"(",
"and",
"shou... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/kernels.py#L353-L359 | [
"def",
"K_r2",
"(",
"self",
",",
"r2",
")",
":",
"r",
"=",
"self",
".",
"_clipped_sqrt",
"(",
"r2",
")",
"return",
"self",
".",
"K_r",
"(",
"r",
")"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | ArcCosine._J | Implements the order dependent family of functions defined in equations
4 to 7 in the reference paper. | gpflow/kernels.py | def _J(self, theta):
"""
Implements the order dependent family of functions defined in equations
4 to 7 in the reference paper.
"""
if self.order == 0:
return np.pi - theta
elif self.order == 1:
return tf.sin(theta) + (np.pi - theta) * tf.cos(theta... | def _J(self, theta):
"""
Implements the order dependent family of functions defined in equations
4 to 7 in the reference paper.
"""
if self.order == 0:
return np.pi - theta
elif self.order == 1:
return tf.sin(theta) + (np.pi - theta) * tf.cos(theta... | [
"Implements",
"the",
"order",
"dependent",
"family",
"of",
"functions",
"defined",
"in",
"equations",
"4",
"to",
"7",
"in",
"the",
"reference",
"paper",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/kernels.py#L627-L638 | [
"def",
"_J",
"(",
"self",
",",
"theta",
")",
":",
"if",
"self",
".",
"order",
"==",
"0",
":",
"return",
"np",
".",
"pi",
"-",
"theta",
"elif",
"self",
".",
"order",
"==",
"1",
":",
"return",
"tf",
".",
"sin",
"(",
"theta",
")",
"+",
"(",
"np"... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Combination.on_separate_dimensions | Checks whether the kernels in the combination act on disjoint subsets
of dimensions. Currently, it is hard to asses whether two slice objects
will overlap, so this will always return False.
:return: Boolean indicator. | gpflow/kernels.py | def on_separate_dimensions(self):
"""
Checks whether the kernels in the combination act on disjoint subsets
of dimensions. Currently, it is hard to asses whether two slice objects
will overlap, so this will always return False.
:return: Boolean indicator.
"""
if n... | def on_separate_dimensions(self):
"""
Checks whether the kernels in the combination act on disjoint subsets
of dimensions. Currently, it is hard to asses whether two slice objects
will overlap, so this will always return False.
:return: Boolean indicator.
"""
if n... | [
"Checks",
"whether",
"the",
"kernels",
"in",
"the",
"combination",
"act",
"on",
"disjoint",
"subsets",
"of",
"dimensions",
".",
"Currently",
"it",
"is",
"hard",
"to",
"asses",
"whether",
"two",
"slice",
"objects",
"will",
"overlap",
"so",
"this",
"will",
"al... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/kernels.py#L810-L827 | [
"def",
"on_separate_dimensions",
"(",
"self",
")",
":",
"if",
"np",
".",
"any",
"(",
"[",
"isinstance",
"(",
"k",
".",
"active_dims",
",",
"slice",
")",
"for",
"k",
"in",
"self",
".",
"kernels",
"]",
")",
":",
"# Be conservative in the case of a slice object... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Log1pe.backward | r"""
Inverse of the softplus transform:
.. math::
x = \log( \exp(y) - 1)
The bound for the input y is [self._lower. inf[, self._lower is
subtracted prior to any calculations. The implementation avoids overflow
explicitly by applying the log sum exp trick:
.. ... | gpflow/transforms.py | def backward(self, y):
r"""
Inverse of the softplus transform:
.. math::
x = \log( \exp(y) - 1)
The bound for the input y is [self._lower. inf[, self._lower is
subtracted prior to any calculations. The implementation avoids overflow
explicitly by applying the... | def backward(self, y):
r"""
Inverse of the softplus transform:
.. math::
x = \log( \exp(y) - 1)
The bound for the input y is [self._lower. inf[, self._lower is
subtracted prior to any calculations. The implementation avoids overflow
explicitly by applying the... | [
"r",
"Inverse",
"of",
"the",
"softplus",
"transform",
":",
"..",
"math",
"::"
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/transforms.py#L162-L189 | [
"def",
"backward",
"(",
"self",
",",
"y",
")",
":",
"ys",
"=",
"np",
".",
"maximum",
"(",
"y",
"-",
"self",
".",
"_lower",
",",
"np",
".",
"finfo",
"(",
"settings",
".",
"float_type",
")",
".",
"eps",
")",
"return",
"ys",
"+",
"np",
".",
"log",... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | LowerTriangular.forward | Transforms from the packed to unpacked representations (numpy)
:param x: packed numpy array. Must have shape `self.num_matrices x triangular_number
:return: Reconstructed numpy array y of shape self.num_matrices x N x N | gpflow/transforms.py | def forward(self, x):
"""
Transforms from the packed to unpacked representations (numpy)
:param x: packed numpy array. Must have shape `self.num_matrices x triangular_number
:return: Reconstructed numpy array y of shape self.num_matrices x N x N
"""
fwd = np.zero... | def forward(self, x):
"""
Transforms from the packed to unpacked representations (numpy)
:param x: packed numpy array. Must have shape `self.num_matrices x triangular_number
:return: Reconstructed numpy array y of shape self.num_matrices x N x N
"""
fwd = np.zero... | [
"Transforms",
"from",
"the",
"packed",
"to",
"unpacked",
"representations",
"(",
"numpy",
")",
":",
"param",
"x",
":",
"packed",
"numpy",
"array",
".",
"Must",
"have",
"shape",
"self",
".",
"num_matrices",
"x",
"triangular_number",
":",
"return",
":",
"Recon... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/transforms.py#L342-L354 | [
"def",
"forward",
"(",
"self",
",",
"x",
")",
":",
"fwd",
"=",
"np",
".",
"zeros",
"(",
"(",
"self",
".",
"num_matrices",
",",
"self",
".",
"N",
",",
"self",
".",
"N",
")",
",",
"settings",
".",
"float_type",
")",
"indices",
"=",
"np",
".",
"tr... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | LowerTriangular.backward | Transforms a series of triangular matrices y to the packed representation x (numpy)
:param y: unpacked numpy array y, shape self.num_matrices x N x N
:return: packed numpy array, x, shape self.num_matrices x triangular number | gpflow/transforms.py | def backward(self, y):
"""
Transforms a series of triangular matrices y to the packed representation x (numpy)
:param y: unpacked numpy array y, shape self.num_matrices x N x N
:return: packed numpy array, x, shape self.num_matrices x triangular number
"""
if sel... | def backward(self, y):
"""
Transforms a series of triangular matrices y to the packed representation x (numpy)
:param y: unpacked numpy array y, shape self.num_matrices x N x N
:return: packed numpy array, x, shape self.num_matrices x triangular number
"""
if sel... | [
"Transforms",
"a",
"series",
"of",
"triangular",
"matrices",
"y",
"to",
"the",
"packed",
"representation",
"x",
"(",
"numpy",
")",
":",
"param",
"y",
":",
"unpacked",
"numpy",
"array",
"y",
"shape",
"self",
".",
"num_matrices",
"x",
"N",
"x",
"N",
":",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/transforms.py#L356-L366 | [
"def",
"backward",
"(",
"self",
",",
"y",
")",
":",
"if",
"self",
".",
"squeeze",
":",
"y",
"=",
"y",
"[",
"None",
",",
":",
",",
":",
"]",
"ind",
"=",
"np",
".",
"tril_indices",
"(",
"self",
".",
"N",
")",
"return",
"np",
".",
"vstack",
"(",... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | LowerTriangular.forward_tensor | Transforms from the packed to unpacked representations (tf.tensors)
:param x: packed tensor. Must have shape `self.num_matrices x triangular_number
:return: Reconstructed tensor y of shape self.num_matrices x N x N | gpflow/transforms.py | def forward_tensor(self, x):
"""
Transforms from the packed to unpacked representations (tf.tensors)
:param x: packed tensor. Must have shape `self.num_matrices x triangular_number
:return: Reconstructed tensor y of shape self.num_matrices x N x N
"""
fwd = vec_t... | def forward_tensor(self, x):
"""
Transforms from the packed to unpacked representations (tf.tensors)
:param x: packed tensor. Must have shape `self.num_matrices x triangular_number
:return: Reconstructed tensor y of shape self.num_matrices x N x N
"""
fwd = vec_t... | [
"Transforms",
"from",
"the",
"packed",
"to",
"unpacked",
"representations",
"(",
"tf",
".",
"tensors",
")",
":",
"param",
"x",
":",
"packed",
"tensor",
".",
"Must",
"have",
"shape",
"self",
".",
"num_matrices",
"x",
"triangular_number",
":",
"return",
":",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/transforms.py#L368-L376 | [
"def",
"forward_tensor",
"(",
"self",
",",
"x",
")",
":",
"fwd",
"=",
"vec_to_tri",
"(",
"x",
",",
"self",
".",
"N",
")",
"return",
"tf",
".",
"squeeze",
"(",
"fwd",
",",
"axis",
"=",
"0",
")",
"if",
"self",
".",
"squeeze",
"else",
"fwd"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | LowerTriangular.backward_tensor | Transforms a series of triangular matrices y to the packed representation x (tf.tensors)
:param y: unpacked tensor with shape self.num_matrices, self.N, self.N
:return: packed tensor with shape self.num_matrices, (self.N**2 + self.N) / 2 | gpflow/transforms.py | def backward_tensor(self, y):
"""
Transforms a series of triangular matrices y to the packed representation x (tf.tensors)
:param y: unpacked tensor with shape self.num_matrices, self.N, self.N
:return: packed tensor with shape self.num_matrices, (self.N**2 + self.N) / 2
... | def backward_tensor(self, y):
"""
Transforms a series of triangular matrices y to the packed representation x (tf.tensors)
:param y: unpacked tensor with shape self.num_matrices, self.N, self.N
:return: packed tensor with shape self.num_matrices, (self.N**2 + self.N) / 2
... | [
"Transforms",
"a",
"series",
"of",
"triangular",
"matrices",
"y",
"to",
"the",
"packed",
"representation",
"x",
"(",
"tf",
".",
"tensors",
")",
":",
"param",
"y",
":",
"unpacked",
"tensor",
"with",
"shape",
"self",
".",
"num_matrices",
"self",
".",
"N",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/transforms.py#L378-L391 | [
"def",
"backward_tensor",
"(",
"self",
",",
"y",
")",
":",
"if",
"self",
".",
"squeeze",
":",
"y",
"=",
"tf",
".",
"expand_dims",
"(",
"y",
",",
"axis",
"=",
"0",
")",
"indices",
"=",
"np",
".",
"vstack",
"(",
"np",
".",
"tril_indices",
"(",
"sel... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | AutoFlow.get_autoflow | Extracts from an object existing dictionary with tensors specified by name.
If there is no such object then new one will be created. Intenally, it appends
autoflow prefix to the name and saves it as an attribute.
:param obj: target GPflow object.
:param name: unique part of autoflow att... | gpflow/core/autoflow.py | def get_autoflow(cls, obj, name):
"""
Extracts from an object existing dictionary with tensors specified by name.
If there is no such object then new one will be created. Intenally, it appends
autoflow prefix to the name and saves it as an attribute.
:param obj: target GPflow ob... | def get_autoflow(cls, obj, name):
"""
Extracts from an object existing dictionary with tensors specified by name.
If there is no such object then new one will be created. Intenally, it appends
autoflow prefix to the name and saves it as an attribute.
:param obj: target GPflow ob... | [
"Extracts",
"from",
"an",
"object",
"existing",
"dictionary",
"with",
"tensors",
"specified",
"by",
"name",
".",
"If",
"there",
"is",
"no",
"such",
"object",
"then",
"new",
"one",
"will",
"be",
"created",
".",
"Intenally",
"it",
"appends",
"autoflow",
"prefi... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/autoflow.py#L28-L46 | [
"def",
"get_autoflow",
"(",
"cls",
",",
"obj",
",",
"name",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"raise",
"ValueError",
"(",
"'Name must be string.'",
")",
"prefix",
"=",
"cls",
".",
"__autoflow_prefix__",
"autoflow_name",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | AutoFlow.clear_autoflow | Clear autoflow's tensor storage.
:param obj: target GPflow object.
:param name: accepts either string value which is unique part of
an internal attribute name or None value. When None value is passed all
storages will be cleared, in other words it clears everything with common
... | gpflow/core/autoflow.py | def clear_autoflow(cls, obj, name=None):
"""
Clear autoflow's tensor storage.
:param obj: target GPflow object.
:param name: accepts either string value which is unique part of
an internal attribute name or None value. When None value is passed all
storages will ... | def clear_autoflow(cls, obj, name=None):
"""
Clear autoflow's tensor storage.
:param obj: target GPflow object.
:param name: accepts either string value which is unique part of
an internal attribute name or None value. When None value is passed all
storages will ... | [
"Clear",
"autoflow",
"s",
"tensor",
"storage",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/core/autoflow.py#L49-L70 | [
"def",
"clear_autoflow",
"(",
"cls",
",",
"obj",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"raise",
"ValueError",
"(",
"'Name must be a string.'",
")",
"prefix",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | VGP.compile | Before calling the standard compile function, check to see if the size
of the data has changed and add variational parameters appropriately.
This is necessary because the shape of the parameters depends on the
shape of the data. | gpflow/models/vgp.py | def compile(self, session=None):
"""
Before calling the standard compile function, check to see if the size
of the data has changed and add variational parameters appropriately.
This is necessary because the shape of the parameters depends on the
shape of the data.
"""
... | def compile(self, session=None):
"""
Before calling the standard compile function, check to see if the size
of the data has changed and add variational parameters appropriately.
This is necessary because the shape of the parameters depends on the
shape of the data.
"""
... | [
"Before",
"calling",
"the",
"standard",
"compile",
"function",
"check",
"to",
"see",
"if",
"the",
"size",
"of",
"the",
"data",
"has",
"changed",
"and",
"add",
"variational",
"parameters",
"appropriately",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/vgp.py#L72-L86 | [
"def",
"compile",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"num_data",
"==",
"self",
".",
"X",
".",
"shape",
"[",
"0",
"]",
":",
"self",
".",
"num_data",
"=",
"self",
".",
"X",
".",
"shape",
"[",
"0",
"]",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | VGP._build_likelihood | r"""
This method computes the variational lower bound on the likelihood,
which is:
E_{q(F)} [ \log p(Y|F) ] - KL[ q(F) || p(F)]
with
q(\mathbf f) = N(\mathbf f \,|\, \boldsymbol \mu, \boldsymbol \Sigma) | gpflow/models/vgp.py | def _build_likelihood(self):
r"""
This method computes the variational lower bound on the likelihood,
which is:
E_{q(F)} [ \log p(Y|F) ] - KL[ q(F) || p(F)]
with
q(\mathbf f) = N(\mathbf f \,|\, \boldsymbol \mu, \boldsymbol \Sigma)
"""
# Get p... | def _build_likelihood(self):
r"""
This method computes the variational lower bound on the likelihood,
which is:
E_{q(F)} [ \log p(Y|F) ] - KL[ q(F) || p(F)]
with
q(\mathbf f) = N(\mathbf f \,|\, \boldsymbol \mu, \boldsymbol \Sigma)
"""
# Get p... | [
"r",
"This",
"method",
"computes",
"the",
"variational",
"lower",
"bound",
"on",
"the",
"likelihood",
"which",
"is",
":"
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/vgp.py#L89-L124 | [
"def",
"_build_likelihood",
"(",
"self",
")",
":",
"# Get prior KL.",
"KL",
"=",
"gauss_kl",
"(",
"self",
".",
"q_mu",
",",
"self",
".",
"q_sqrt",
")",
"# Get conditionals",
"K",
"=",
"self",
".",
"kern",
".",
"K",
"(",
"self",
".",
"X",
")",
"+",
"t... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | VGP_opper_archambeau.compile | Before calling the standard compile function, check to see if the size
of the data has changed and add variational parameters appropriately.
This is necessary because the shape of the parameters depends on the
shape of the data. | gpflow/models/vgp.py | def compile(self, session=None):
"""
Before calling the standard compile function, check to see if the size
of the data has changed and add variational parameters appropriately.
This is necessary because the shape of the parameters depends on the
shape of the data.
"""
... | def compile(self, session=None):
"""
Before calling the standard compile function, check to see if the size
of the data has changed and add variational parameters appropriately.
This is necessary because the shape of the parameters depends on the
shape of the data.
"""
... | [
"Before",
"calling",
"the",
"standard",
"compile",
"function",
"check",
"to",
"see",
"if",
"the",
"size",
"of",
"the",
"data",
"has",
"changed",
"and",
"add",
"variational",
"parameters",
"appropriately",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/vgp.py#L181-L194 | [
"def",
"compile",
"(",
"self",
",",
"session",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"num_data",
"==",
"self",
".",
"X",
".",
"shape",
"[",
"0",
"]",
":",
"self",
".",
"num_data",
"=",
"self",
".",
"X",
".",
"shape",
"[",
"0",
"]",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | VGP_opper_archambeau._build_likelihood | r"""
q_alpha, q_lambda are variational parameters, size N x R
This method computes the variational lower bound on the likelihood,
which is:
E_{q(F)} [ \log p(Y|F) ] - KL[ q(F) || p(F)]
with
q(f) = N(f | K alpha + mean, [K^-1 + diag(square(lambda))]^-1) . | gpflow/models/vgp.py | def _build_likelihood(self):
r"""
q_alpha, q_lambda are variational parameters, size N x R
This method computes the variational lower bound on the likelihood,
which is:
E_{q(F)} [ \log p(Y|F) ] - KL[ q(F) || p(F)]
with
q(f) = N(f | K alpha + mean, [K^-1 + ... | def _build_likelihood(self):
r"""
q_alpha, q_lambda are variational parameters, size N x R
This method computes the variational lower bound on the likelihood,
which is:
E_{q(F)} [ \log p(Y|F) ] - KL[ q(F) || p(F)]
with
q(f) = N(f | K alpha + mean, [K^-1 + ... | [
"r",
"q_alpha",
"q_lambda",
"are",
"variational",
"parameters",
"size",
"N",
"x",
"R",
"This",
"method",
"computes",
"the",
"variational",
"lower",
"bound",
"on",
"the",
"likelihood",
"which",
"is",
":",
"E_",
"{",
"q",
"(",
"F",
")",
"}",
"[",
"\\",
"... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/vgp.py#L197-L228 | [
"def",
"_build_likelihood",
"(",
"self",
")",
":",
"K",
"=",
"self",
".",
"kern",
".",
"K",
"(",
"self",
".",
"X",
")",
"K_alpha",
"=",
"tf",
".",
"matmul",
"(",
"K",
",",
"self",
".",
"q_alpha",
")",
"f_mean",
"=",
"K_alpha",
"+",
"self",
".",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | VGP_opper_archambeau._build_predict | The posterior variance of F is given by
q(f) = N(f | K alpha + mean, [K^-1 + diag(lambda**2)]^-1)
Here we project this to F*, the values of the GP at Xnew which is given
by
q(F*) = N ( F* | K_{*F} alpha + mean, K_{**} - K_{*f}[K_{ff} +
di... | gpflow/models/vgp.py | def _build_predict(self, Xnew, full_cov=False):
"""
The posterior variance of F is given by
q(f) = N(f | K alpha + mean, [K^-1 + diag(lambda**2)]^-1)
Here we project this to F*, the values of the GP at Xnew which is given
by
q(F*) = N ( F* | K_{*F} alpha + mean, K_... | def _build_predict(self, Xnew, full_cov=False):
"""
The posterior variance of F is given by
q(f) = N(f | K alpha + mean, [K^-1 + diag(lambda**2)]^-1)
Here we project this to F*, the values of the GP at Xnew which is given
by
q(F*) = N ( F* | K_{*F} alpha + mean, K_... | [
"The",
"posterior",
"variance",
"of",
"F",
"is",
"given",
"by",
"q",
"(",
"f",
")",
"=",
"N",
"(",
"f",
"|",
"K",
"alpha",
"+",
"mean",
"[",
"K^",
"-",
"1",
"+",
"diag",
"(",
"lambda",
"**",
"2",
")",
"]",
"^",
"-",
"1",
")",
"Here",
"we",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/vgp.py#L231-L257 | [
"def",
"_build_predict",
"(",
"self",
",",
"Xnew",
",",
"full_cov",
"=",
"False",
")",
":",
"# compute kernel things",
"Kx",
"=",
"self",
".",
"kern",
".",
"K",
"(",
"self",
".",
"X",
",",
"Xnew",
")",
"K",
"=",
"self",
".",
"kern",
".",
"K",
"(",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | SGPMC._build_likelihood | This function computes the optimal density for v, q*(v), up to a constant | gpflow/models/sgpmc.py | def _build_likelihood(self):
"""
This function computes the optimal density for v, q*(v), up to a constant
"""
# get the (marginals of) q(f): exactly predicting!
fmean, fvar = self._build_predict(self.X, full_cov=False)
return tf.reduce_sum(self.likelihood.variational_exp... | def _build_likelihood(self):
"""
This function computes the optimal density for v, q*(v), up to a constant
"""
# get the (marginals of) q(f): exactly predicting!
fmean, fvar = self._build_predict(self.X, full_cov=False)
return tf.reduce_sum(self.likelihood.variational_exp... | [
"This",
"function",
"computes",
"the",
"optimal",
"density",
"for",
"v",
"q",
"*",
"(",
"v",
")",
"up",
"to",
"a",
"constant"
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/sgpmc.py#L80-L86 | [
"def",
"_build_likelihood",
"(",
"self",
")",
":",
"# get the (marginals of) q(f): exactly predicting!",
"fmean",
",",
"fvar",
"=",
"self",
".",
"_build_predict",
"(",
"self",
".",
"X",
",",
"full_cov",
"=",
"False",
")",
"return",
"tf",
".",
"reduce_sum",
"(",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | _parse | Very simple config values parser. | gpflow/_settings.py | def _parse(string):
"""
Very simple config values parser.
"""
if not isinstance(string, str):
raise ValueError('Config value "{0}" expected to be string.'
.format(string))
if string in ['true', 'True']:
return True
elif string in ['false', 'False']:
... | def _parse(string):
"""
Very simple config values parser.
"""
if not isinstance(string, str):
raise ValueError('Config value "{0}" expected to be string.'
.format(string))
if string in ['true', 'True']:
return True
elif string in ['false', 'False']:
... | [
"Very",
"simple",
"config",
"values",
"parser",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/_settings.py#L105-L127 | [
"def",
"_parse",
"(",
"string",
")",
":",
"if",
"not",
"isinstance",
"(",
"string",
",",
"str",
")",
":",
"raise",
"ValueError",
"(",
"'Config value \"{0}\" expected to be string.'",
".",
"format",
"(",
"string",
")",
")",
"if",
"string",
"in",
"[",
"'true'"... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | _namedtuplify | Make the dictionary into a nested series of named tuples.
This is what allows accessing by attribute: settings.numerics.jitter
Thank you https://gist.github.com/hangtwenty/5960435 | gpflow/_settings.py | def _namedtuplify(mapping):
"""
Make the dictionary into a nested series of named tuples.
This is what allows accessing by attribute: settings.numerics.jitter
Thank you https://gist.github.com/hangtwenty/5960435
"""
if isinstance(mapping, collections.Mapping):
for key, value in list(mapp... | def _namedtuplify(mapping):
"""
Make the dictionary into a nested series of named tuples.
This is what allows accessing by attribute: settings.numerics.jitter
Thank you https://gist.github.com/hangtwenty/5960435
"""
if isinstance(mapping, collections.Mapping):
for key, value in list(mapp... | [
"Make",
"the",
"dictionary",
"into",
"a",
"nested",
"series",
"of",
"named",
"tuples",
".",
"This",
"is",
"what",
"allows",
"accessing",
"by",
"attribute",
":",
"settings",
".",
"numerics",
".",
"jitter",
"Thank",
"you",
"https",
":",
"//",
"gist",
".",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/_settings.py#L130-L145 | [
"def",
"_namedtuplify",
"(",
"mapping",
")",
":",
"if",
"isinstance",
"(",
"mapping",
",",
"collections",
".",
"Mapping",
")",
":",
"for",
"key",
",",
"value",
"in",
"list",
"(",
"mapping",
".",
"items",
"(",
")",
")",
":",
"mapping",
"[",
"key",
"]"... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | _read_config_file | Reads config file.
First look for config file in the current directory, then in the
user's home directory, then in the same directory as this file.
Tries to find config file both with and without preceeding 'dot'
for hidden files (prefer non-hidden). | gpflow/_settings.py | def _read_config_file(path=None):
"""
Reads config file.
First look for config file in the current directory, then in the
user's home directory, then in the same directory as this file.
Tries to find config file both with and without preceeding 'dot'
for hidden files (prefer non-hidden).
"""... | def _read_config_file(path=None):
"""
Reads config file.
First look for config file in the current directory, then in the
user's home directory, then in the same directory as this file.
Tries to find config file both with and without preceeding 'dot'
for hidden files (prefer non-hidden).
"""... | [
"Reads",
"config",
"file",
".",
"First",
"look",
"for",
"config",
"file",
"in",
"the",
"current",
"directory",
"then",
"in",
"the",
"user",
"s",
"home",
"directory",
"then",
"in",
"the",
"same",
"directory",
"as",
"this",
"file",
".",
"Tries",
"to",
"fin... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/_settings.py#L148-L170 | [
"def",
"_read_config_file",
"(",
"path",
"=",
"None",
")",
":",
"cfg",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"if",
"path",
"is",
"None",
":",
"# pragma: no cover",
"dirs",
"=",
"[",
"os",
".",
"curdir",
",",
"os",
".",
"path",
".",
"expan... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | mvhermgauss | Return the evaluation locations 'xn', and weights 'wn' for a multivariate
Gauss-Hermite quadrature.
The outputs can be used to approximate the following type of integral:
int exp(-x)*f(x) dx ~ sum_i w[i,:]*f(x[i,:])
:param H: Number of Gauss-Hermite evaluation points.
:param D: Number of input dim... | gpflow/quadrature.py | def mvhermgauss(H: int, D: int):
"""
Return the evaluation locations 'xn', and weights 'wn' for a multivariate
Gauss-Hermite quadrature.
The outputs can be used to approximate the following type of integral:
int exp(-x)*f(x) dx ~ sum_i w[i,:]*f(x[i,:])
:param H: Number of Gauss-Hermite evaluat... | def mvhermgauss(H: int, D: int):
"""
Return the evaluation locations 'xn', and weights 'wn' for a multivariate
Gauss-Hermite quadrature.
The outputs can be used to approximate the following type of integral:
int exp(-x)*f(x) dx ~ sum_i w[i,:]*f(x[i,:])
:param H: Number of Gauss-Hermite evaluat... | [
"Return",
"the",
"evaluation",
"locations",
"xn",
"and",
"weights",
"wn",
"for",
"a",
"multivariate",
"Gauss",
"-",
"Hermite",
"quadrature",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/quadrature.py#L31-L46 | [
"def",
"mvhermgauss",
"(",
"H",
":",
"int",
",",
"D",
":",
"int",
")",
":",
"gh_x",
",",
"gh_w",
"=",
"hermgauss",
"(",
"H",
")",
"x",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"itertools",
".",
"product",
"(",
"*",
"(",
"gh_x",
",",
")",
"*... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | mvnquad | Computes N Gaussian expectation integrals of a single function 'f'
using Gauss-Hermite quadrature.
:param f: integrand function. Takes one input of shape ?xD.
:param means: NxD
:param covs: NxDxD
:param H: Number of Gauss-Hermite evaluation points.
:param Din: Number of input dimensions. Needs t... | gpflow/quadrature.py | def mvnquad(func, means, covs, H: int, Din: int=None, Dout=None):
"""
Computes N Gaussian expectation integrals of a single function 'f'
using Gauss-Hermite quadrature.
:param f: integrand function. Takes one input of shape ?xD.
:param means: NxD
:param covs: NxDxD
:param H: Number of Gauss-... | def mvnquad(func, means, covs, H: int, Din: int=None, Dout=None):
"""
Computes N Gaussian expectation integrals of a single function 'f'
using Gauss-Hermite quadrature.
:param f: integrand function. Takes one input of shape ?xD.
:param means: NxD
:param covs: NxDxD
:param H: Number of Gauss-... | [
"Computes",
"N",
"Gaussian",
"expectation",
"integrals",
"of",
"a",
"single",
"function",
"f",
"using",
"Gauss",
"-",
"Hermite",
"quadrature",
".",
":",
"param",
"f",
":",
"integrand",
"function",
".",
"Takes",
"one",
"input",
"of",
"shape",
"?xD",
".",
":... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/quadrature.py#L49-L92 | [
"def",
"mvnquad",
"(",
"func",
",",
"means",
",",
"covs",
",",
"H",
":",
"int",
",",
"Din",
":",
"int",
"=",
"None",
",",
"Dout",
"=",
"None",
")",
":",
"# Figure out input shape information",
"if",
"Din",
"is",
"None",
":",
"Din",
"=",
"means",
".",... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | ndiagquad | Computes N Gaussian expectation integrals of one or more functions
using Gauss-Hermite quadrature. The Gaussians must be independent.
:param funcs: the integrand(s):
Callable or Iterable of Callables that operates elementwise, on the following arguments:
- `Din` positional arguments to match Fm... | gpflow/quadrature.py | def ndiagquad(funcs, H: int, Fmu, Fvar, logspace: bool=False, **Ys):
"""
Computes N Gaussian expectation integrals of one or more functions
using Gauss-Hermite quadrature. The Gaussians must be independent.
:param funcs: the integrand(s):
Callable or Iterable of Callables that operates elementw... | def ndiagquad(funcs, H: int, Fmu, Fvar, logspace: bool=False, **Ys):
"""
Computes N Gaussian expectation integrals of one or more functions
using Gauss-Hermite quadrature. The Gaussians must be independent.
:param funcs: the integrand(s):
Callable or Iterable of Callables that operates elementw... | [
"Computes",
"N",
"Gaussian",
"expectation",
"integrals",
"of",
"one",
"or",
"more",
"functions",
"using",
"Gauss",
"-",
"Hermite",
"quadrature",
".",
"The",
"Gaussians",
"must",
"be",
"independent",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/quadrature.py#L95-L198 | [
"def",
"ndiagquad",
"(",
"funcs",
",",
"H",
":",
"int",
",",
"Fmu",
",",
"Fvar",
",",
"logspace",
":",
"bool",
"=",
"False",
",",
"*",
"*",
"Ys",
")",
":",
"def",
"unify",
"(",
"f_list",
")",
":",
"\"\"\"\n Stack a list of means/vars into a full blo... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | ndiag_mc | Computes N Gaussian expectation integrals of one or more functions
using Monte Carlo samples. The Gaussians must be independent.
:param funcs: the integrand(s):
Callable or Iterable of Callables that operates elementwise
:param S: number of Monte Carlo sampling points
:param Fmu: array/tensor
... | gpflow/quadrature.py | def ndiag_mc(funcs, S: int, Fmu, Fvar, logspace: bool=False, epsilon=None, **Ys):
"""
Computes N Gaussian expectation integrals of one or more functions
using Monte Carlo samples. The Gaussians must be independent.
:param funcs: the integrand(s):
Callable or Iterable of Callables that operates ... | def ndiag_mc(funcs, S: int, Fmu, Fvar, logspace: bool=False, epsilon=None, **Ys):
"""
Computes N Gaussian expectation integrals of one or more functions
using Monte Carlo samples. The Gaussians must be independent.
:param funcs: the integrand(s):
Callable or Iterable of Callables that operates ... | [
"Computes",
"N",
"Gaussian",
"expectation",
"integrals",
"of",
"one",
"or",
"more",
"functions",
"using",
"Monte",
"Carlo",
"samples",
".",
"The",
"Gaussians",
"must",
"be",
"independent",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/quadrature.py#L201-L244 | [
"def",
"ndiag_mc",
"(",
"funcs",
",",
"S",
":",
"int",
",",
"Fmu",
",",
"Fvar",
",",
"logspace",
":",
"bool",
"=",
"False",
",",
"epsilon",
"=",
"None",
",",
"*",
"*",
"Ys",
")",
":",
"N",
",",
"D",
"=",
"tf",
".",
"shape",
"(",
"Fmu",
")",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | name_scope | This decorator wraps a function so that it runs inside a TensorFlow
name scope. The name is given by the `name` option; if this is None,
then the name of the function will be used.
```
>>> @name_scope()
>>> def foo(...):
>>> # now runs inside scope "foo"
>>> @name_scope('bar')
>>> de... | gpflow/decors.py | def name_scope(name=None):
"""
This decorator wraps a function so that it runs inside a TensorFlow
name scope. The name is given by the `name` option; if this is None,
then the name of the function will be used.
```
>>> @name_scope()
>>> def foo(...):
>>> # now runs inside scope "foo... | def name_scope(name=None):
"""
This decorator wraps a function so that it runs inside a TensorFlow
name scope. The name is given by the `name` option; if this is None,
then the name of the function will be used.
```
>>> @name_scope()
>>> def foo(...):
>>> # now runs inside scope "foo... | [
"This",
"decorator",
"wraps",
"a",
"function",
"so",
"that",
"it",
"runs",
"inside",
"a",
"TensorFlow",
"name",
"scope",
".",
"The",
"name",
"is",
"given",
"by",
"the",
"name",
"option",
";",
"if",
"this",
"is",
"None",
"then",
"the",
"name",
"of",
"th... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/decors.py#L30-L51 | [
"def",
"name_scope",
"(",
"name",
"=",
"None",
")",
":",
"def",
"name_scope_wrapper_decorator",
"(",
"method",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"method",
")",
"def",
"name_scope_wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | params_as_tensors | The `params_as_tensors` decorator converts representation for parameters into
their unconstrained tensors, and data holders to their data tensors inside
wrapped function, subject to this function is a member of parameterized object. | gpflow/decors.py | def params_as_tensors(method):
"""
The `params_as_tensors` decorator converts representation for parameters into
their unconstrained tensors, and data holders to their data tensors inside
wrapped function, subject to this function is a member of parameterized object.
"""
@functools.wraps(method)... | def params_as_tensors(method):
"""
The `params_as_tensors` decorator converts representation for parameters into
their unconstrained tensors, and data holders to their data tensors inside
wrapped function, subject to this function is a member of parameterized object.
"""
@functools.wraps(method)... | [
"The",
"params_as_tensors",
"decorator",
"converts",
"representation",
"for",
"parameters",
"into",
"their",
"unconstrained",
"tensors",
"and",
"data",
"holders",
"to",
"their",
"data",
"tensors",
"inside",
"wrapped",
"function",
"subject",
"to",
"this",
"function",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/decors.py#L54-L71 | [
"def",
"params_as_tensors",
"(",
"method",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"method",
")",
"def",
"tensor_mode_wrapper",
"(",
"obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"Paramet... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | params_as_tensors_for | Context manager which changes the representation of parameters and data holders
for the specific parameterized object(s).
This can also be used to turn off tensor conversion functions wrapped with
`params_as_tensors`:
```
@gpflow.params_as_tensors
def compute_something(self): # self is paramet... | gpflow/decors.py | def params_as_tensors_for(*objs, convert=True):
"""
Context manager which changes the representation of parameters and data holders
for the specific parameterized object(s).
This can also be used to turn off tensor conversion functions wrapped with
`params_as_tensors`:
```
@gpflow.params_as... | def params_as_tensors_for(*objs, convert=True):
"""
Context manager which changes the representation of parameters and data holders
for the specific parameterized object(s).
This can also be used to turn off tensor conversion functions wrapped with
`params_as_tensors`:
```
@gpflow.params_as... | [
"Context",
"manager",
"which",
"changes",
"the",
"representation",
"of",
"parameters",
"and",
"data",
"holders",
"for",
"the",
"specific",
"parameterized",
"object",
"(",
"s",
")",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/decors.py#L118-L144 | [
"def",
"params_as_tensors_for",
"(",
"*",
"objs",
",",
"convert",
"=",
"True",
")",
":",
"objs",
"=",
"set",
"(",
"objs",
")",
"# remove duplicate objects so the tensor mode won't be changed before saving",
"prev_values",
"=",
"[",
"_params_as_tensors_enter",
"(",
"o",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | gauss_kl | Compute the KL divergence KL[q || p] between
q(x) = N(q_mu, q_sqrt^2)
and
p(x) = N(0, K)
We assume N multiple independent distributions, given by the columns of
q_mu and the last dimension of q_sqrt. Returns the sum of the divergences.
q_mu is a matrix [M, L], each column contains... | gpflow/kullback_leiblers.py | def gauss_kl(q_mu, q_sqrt, K=None, *, K_cholesky=None):
"""
Compute the KL divergence KL[q || p] between
q(x) = N(q_mu, q_sqrt^2)
and
p(x) = N(0, K)
We assume N multiple independent distributions, given by the columns of
q_mu and the last dimension of q_sqrt. Returns the sum of... | def gauss_kl(q_mu, q_sqrt, K=None, *, K_cholesky=None):
"""
Compute the KL divergence KL[q || p] between
q(x) = N(q_mu, q_sqrt^2)
and
p(x) = N(0, K)
We assume N multiple independent distributions, given by the columns of
q_mu and the last dimension of q_sqrt. Returns the sum of... | [
"Compute",
"the",
"KL",
"divergence",
"KL",
"[",
"q",
"||",
"p",
"]",
"between"
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/kullback_leiblers.py#L25-L116 | [
"def",
"gauss_kl",
"(",
"q_mu",
",",
"q_sqrt",
",",
"K",
"=",
"None",
",",
"*",
",",
"K_cholesky",
"=",
"None",
")",
":",
"if",
"(",
"K",
"is",
"not",
"None",
")",
"and",
"(",
"K_cholesky",
"is",
"not",
"None",
")",
":",
"raise",
"ValueError",
"(... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | PCA_reduce | A helpful function for linearly reducing the dimensionality of the data X
to Q.
:param X: data array of size N (number of points) x D (dimensions)
:param Q: Number of latent dimensions, Q < D
:return: PCA projection array of size N x Q. | gpflow/models/gplvm.py | def PCA_reduce(X, Q):
"""
A helpful function for linearly reducing the dimensionality of the data X
to Q.
:param X: data array of size N (number of points) x D (dimensions)
:param Q: Number of latent dimensions, Q < D
:return: PCA projection array of size N x Q.
"""
assert Q <= X.shape[1... | def PCA_reduce(X, Q):
"""
A helpful function for linearly reducing the dimensionality of the data X
to Q.
:param X: data array of size N (number of points) x D (dimensions)
:param Q: Number of latent dimensions, Q < D
:return: PCA projection array of size N x Q.
"""
assert Q <= X.shape[1... | [
"A",
"helpful",
"function",
"for",
"linearly",
"reducing",
"the",
"dimensionality",
"of",
"the",
"data",
"X",
"to",
"Q",
".",
":",
"param",
"X",
":",
"data",
"array",
"of",
"size",
"N",
"(",
"number",
"of",
"points",
")",
"x",
"D",
"(",
"dimensions",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/gplvm.py#L209-L220 | [
"def",
"PCA_reduce",
"(",
"X",
",",
"Q",
")",
":",
"assert",
"Q",
"<=",
"X",
".",
"shape",
"[",
"1",
"]",
",",
"'Cannot have more latent dimensions than observed'",
"evals",
",",
"evecs",
"=",
"np",
".",
"linalg",
".",
"eigh",
"(",
"np",
".",
"cov",
"(... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | BayesianGPLVM._build_likelihood | Construct a tensorflow function to compute the bound on the marginal
likelihood. | gpflow/models/gplvm.py | def _build_likelihood(self):
"""
Construct a tensorflow function to compute the bound on the marginal
likelihood.
"""
pX = DiagonalGaussian(self.X_mean, self.X_var)
num_inducing = len(self.feature)
psi0 = tf.reduce_sum(expectation(pX, self.kern))
psi1 = e... | def _build_likelihood(self):
"""
Construct a tensorflow function to compute the bound on the marginal
likelihood.
"""
pX = DiagonalGaussian(self.X_mean, self.X_var)
num_inducing = len(self.feature)
psi0 = tf.reduce_sum(expectation(pX, self.kern))
psi1 = e... | [
"Construct",
"a",
"tensorflow",
"function",
"to",
"compute",
"the",
"bound",
"on",
"the",
"marginal",
"likelihood",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/gplvm.py#L123-L166 | [
"def",
"_build_likelihood",
"(",
"self",
")",
":",
"pX",
"=",
"DiagonalGaussian",
"(",
"self",
".",
"X_mean",
",",
"self",
".",
"X_var",
")",
"num_inducing",
"=",
"len",
"(",
"self",
".",
"feature",
")",
"psi0",
"=",
"tf",
".",
"reduce_sum",
"(",
"expe... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | BayesianGPLVM._build_predict | Compute the mean and variance of the latent function at some new points.
Note that this is very similar to the SGPR prediction, for which
there are notes in the SGPR notebook.
:param Xnew: Point to predict at. | gpflow/models/gplvm.py | def _build_predict(self, Xnew, full_cov=False):
"""
Compute the mean and variance of the latent function at some new points.
Note that this is very similar to the SGPR prediction, for which
there are notes in the SGPR notebook.
:param Xnew: Point to predict at.
"""
... | def _build_predict(self, Xnew, full_cov=False):
"""
Compute the mean and variance of the latent function at some new points.
Note that this is very similar to the SGPR prediction, for which
there are notes in the SGPR notebook.
:param Xnew: Point to predict at.
"""
... | [
"Compute",
"the",
"mean",
"and",
"variance",
"of",
"the",
"latent",
"function",
"at",
"some",
"new",
"points",
".",
"Note",
"that",
"this",
"is",
"very",
"similar",
"to",
"the",
"SGPR",
"prediction",
"for",
"which",
"there",
"are",
"notes",
"in",
"the",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/models/gplvm.py#L169-L206 | [
"def",
"_build_predict",
"(",
"self",
",",
"Xnew",
",",
"full_cov",
"=",
"False",
")",
":",
"pX",
"=",
"DiagonalGaussian",
"(",
"self",
".",
"X_mean",
",",
"self",
".",
"X_var",
")",
"num_inducing",
"=",
"len",
"(",
"self",
".",
"feature",
")",
"psi1",... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | _conditional | Multi-output GP with independent GP priors.
Number of latent processes equals the number of outputs (L = P).
The covariance matrices used to calculate the conditional have the following shape:
- Kuu: P x M x M
- Kuf: P x M x N
- Kff: P x N or P x N x N
Further reference
-----------------
... | gpflow/multioutput/conditionals.py | def _conditional(Xnew, feat, kern, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False):
"""
Multi-output GP with independent GP priors.
Number of latent processes equals the number of outputs (L = P).
The covariance matrices used to calculate the conditional have the following shape:... | def _conditional(Xnew, feat, kern, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False):
"""
Multi-output GP with independent GP priors.
Number of latent processes equals the number of outputs (L = P).
The covariance matrices used to calculate the conditional have the following shape:... | [
"Multi",
"-",
"output",
"GP",
"with",
"independent",
"GP",
"priors",
".",
"Number",
"of",
"latent",
"processes",
"equals",
"the",
"number",
"of",
"outputs",
"(",
"L",
"=",
"P",
")",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/multioutput/conditionals.py#L90-L133 | [
"def",
"_conditional",
"(",
"Xnew",
",",
"feat",
",",
"kern",
",",
"f",
",",
"*",
",",
"full_cov",
"=",
"False",
",",
"full_output_cov",
"=",
"False",
",",
"q_sqrt",
"=",
"None",
",",
"white",
"=",
"False",
")",
":",
"logger",
".",
"debug",
"(",
"\... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | _conditional | Multi-output GP with fully correlated inducing variables.
The inducing variables are shaped in the same way as evaluations of K, to allow a default
inducing point scheme for multi-output kernels.
The covariance matrices used to calculate the conditional have the following shape:
- Kuu: M x L x M x L
... | gpflow/multioutput/conditionals.py | def _conditional(Xnew, feat, kern, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False):
"""
Multi-output GP with fully correlated inducing variables.
The inducing variables are shaped in the same way as evaluations of K, to allow a default
inducing point scheme for multi-output kernel... | def _conditional(Xnew, feat, kern, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False):
"""
Multi-output GP with fully correlated inducing variables.
The inducing variables are shaped in the same way as evaluations of K, to allow a default
inducing point scheme for multi-output kernel... | [
"Multi",
"-",
"output",
"GP",
"with",
"fully",
"correlated",
"inducing",
"variables",
".",
"The",
"inducing",
"variables",
"are",
"shaped",
"in",
"the",
"same",
"way",
"as",
"evaluations",
"of",
"K",
"to",
"allow",
"a",
"default",
"inducing",
"point",
"schem... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/multioutput/conditionals.py#L168-L209 | [
"def",
"_conditional",
"(",
"Xnew",
",",
"feat",
",",
"kern",
",",
"f",
",",
"*",
",",
"full_cov",
"=",
"False",
",",
"full_output_cov",
"=",
"False",
",",
"q_sqrt",
"=",
"None",
",",
"white",
"=",
"False",
")",
":",
"logger",
".",
"debug",
"(",
"\... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | _conditional | Most efficient routine to project L independent latent gps through a mixing matrix W.
The mixing matrix is a member of the `SeparateMixedMok` and has shape P x L.
The covariance matrices used to calculate the conditional have the following shape:
- Kuu: L x M x M
- Kuf: L x M x N
- Kff: L x N or L ... | gpflow/multioutput/conditionals.py | def _conditional(Xnew, feat, kern, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False):
"""
Most efficient routine to project L independent latent gps through a mixing matrix W.
The mixing matrix is a member of the `SeparateMixedMok` and has shape P x L.
The covariance matrices used ... | def _conditional(Xnew, feat, kern, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False):
"""
Most efficient routine to project L independent latent gps through a mixing matrix W.
The mixing matrix is a member of the `SeparateMixedMok` and has shape P x L.
The covariance matrices used ... | [
"Most",
"efficient",
"routine",
"to",
"project",
"L",
"independent",
"latent",
"gps",
"through",
"a",
"mixing",
"matrix",
"W",
".",
"The",
"mixing",
"matrix",
"is",
"a",
"member",
"of",
"the",
"SeparateMixedMok",
"and",
"has",
"shape",
"P",
"x",
"L",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/multioutput/conditionals.py#L214-L236 | [
"def",
"_conditional",
"(",
"Xnew",
",",
"feat",
",",
"kern",
",",
"f",
",",
"*",
",",
"full_cov",
"=",
"False",
",",
"full_output_cov",
"=",
"False",
",",
"q_sqrt",
"=",
"None",
",",
"white",
"=",
"False",
")",
":",
"logger",
".",
"debug",
"(",
"\... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | _sample_conditional | `sample_conditional` will return a sample from the conditinoal distribution.
In most cases this means calculating the conditional mean m and variance v and then
returning m + sqrt(v) * eps, with eps ~ N(0, 1).
However, for some combinations of Mok and Mof more efficient sampling routines exists.
The dis... | gpflow/multioutput/conditionals.py | def _sample_conditional(Xnew, feat, kern, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False, num_samples=None):
"""
`sample_conditional` will return a sample from the conditinoal distribution.
In most cases this means calculating the conditional mean m and variance v and then
returni... | def _sample_conditional(Xnew, feat, kern, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False, num_samples=None):
"""
`sample_conditional` will return a sample from the conditinoal distribution.
In most cases this means calculating the conditional mean m and variance v and then
returni... | [
"sample_conditional",
"will",
"return",
"a",
"sample",
"from",
"the",
"conditinoal",
"distribution",
".",
"In",
"most",
"cases",
"this",
"means",
"calculating",
"the",
"conditional",
"mean",
"m",
"and",
"variance",
"v",
"and",
"then",
"returning",
"m",
"+",
"s... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/multioutput/conditionals.py#L245-L267 | [
"def",
"_sample_conditional",
"(",
"Xnew",
",",
"feat",
",",
"kern",
",",
"f",
",",
"*",
",",
"full_cov",
"=",
"False",
",",
"full_output_cov",
"=",
"False",
",",
"q_sqrt",
"=",
"None",
",",
"white",
"=",
"False",
",",
"num_samples",
"=",
"None",
")",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | independent_interdomain_conditional | The inducing outputs live in the g-space (R^L).
Interdomain conditional calculation.
:param Kmn: M x L x N x P
:param Kmm: L x M x M
:param Knn: N x P or N x N or P x N x N or N x P x N x P
:param f: data matrix, M x L
:param q_sqrt: L x M x M or M x L
:param full_cov: calculate cov... | gpflow/multioutput/conditionals.py | def independent_interdomain_conditional(Kmn, Kmm, Knn, f, *, full_cov=False, full_output_cov=False,
q_sqrt=None, white=False):
"""
The inducing outputs live in the g-space (R^L).
Interdomain conditional calculation.
:param Kmn: M x L x N x P
:param Kmm: L x M... | def independent_interdomain_conditional(Kmn, Kmm, Knn, f, *, full_cov=False, full_output_cov=False,
q_sqrt=None, white=False):
"""
The inducing outputs live in the g-space (R^L).
Interdomain conditional calculation.
:param Kmn: M x L x N x P
:param Kmm: L x M... | [
"The",
"inducing",
"outputs",
"live",
"in",
"the",
"g",
"-",
"space",
"(",
"R^L",
")",
".",
"Interdomain",
"conditional",
"calculation",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/multioutput/conditionals.py#L274-L339 | [
"def",
"independent_interdomain_conditional",
"(",
"Kmn",
",",
"Kmm",
",",
"Knn",
",",
"f",
",",
"*",
",",
"full_cov",
"=",
"False",
",",
"full_output_cov",
"=",
"False",
",",
"q_sqrt",
"=",
"None",
",",
"white",
"=",
"False",
")",
":",
"logger",
".",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | fully_correlated_conditional | This function handles conditioning of multi-output GPs in the case where the conditioning
points are all fully correlated, in both the prior and posterior.
:param Kmn: LM x N x P
:param Kmm: LM x LM
:param Knn: N x P or N x P x N x P
:param f: data matrix, LM x 1
:param q_sqrt: 1 x LM x LM or 1... | gpflow/multioutput/conditionals.py | def fully_correlated_conditional(Kmn, Kmm, Knn, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False):
"""
This function handles conditioning of multi-output GPs in the case where the conditioning
points are all fully correlated, in both the prior and posterior.
:param Kmn: LM x N x P
... | def fully_correlated_conditional(Kmn, Kmm, Knn, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False):
"""
This function handles conditioning of multi-output GPs in the case where the conditioning
points are all fully correlated, in both the prior and posterior.
:param Kmn: LM x N x P
... | [
"This",
"function",
"handles",
"conditioning",
"of",
"multi",
"-",
"output",
"GPs",
"in",
"the",
"case",
"where",
"the",
"conditioning",
"points",
"are",
"all",
"fully",
"correlated",
"in",
"both",
"the",
"prior",
"and",
"posterior",
".",
":",
"param",
"Kmn"... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/multioutput/conditionals.py#L342-L360 | [
"def",
"fully_correlated_conditional",
"(",
"Kmn",
",",
"Kmm",
",",
"Knn",
",",
"f",
",",
"*",
",",
"full_cov",
"=",
"False",
",",
"full_output_cov",
"=",
"False",
",",
"q_sqrt",
"=",
"None",
",",
"white",
"=",
"False",
")",
":",
"m",
",",
"v",
"=",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | fully_correlated_conditional_repeat | This function handles conditioning of multi-output GPs in the case where the conditioning
points are all fully correlated, in both the prior and posterior.
Note: This conditional can handle 'repetitions' R, given in `f` and `q_sqrt`.
:param Kmn: LM x N x P
:param Kmm: LM x LM
:param Knn: N x P or ... | gpflow/multioutput/conditionals.py | def fully_correlated_conditional_repeat(Kmn, Kmm, Knn, f, *, full_cov=False, full_output_cov=False, q_sqrt=None,
white=False):
"""
This function handles conditioning of multi-output GPs in the case where the conditioning
points are all fully correlated, in both the pr... | def fully_correlated_conditional_repeat(Kmn, Kmm, Knn, f, *, full_cov=False, full_output_cov=False, q_sqrt=None,
white=False):
"""
This function handles conditioning of multi-output GPs in the case where the conditioning
points are all fully correlated, in both the pr... | [
"This",
"function",
"handles",
"conditioning",
"of",
"multi",
"-",
"output",
"GPs",
"in",
"the",
"case",
"where",
"the",
"conditioning",
"points",
"are",
"all",
"fully",
"correlated",
"in",
"both",
"the",
"prior",
"and",
"posterior",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/multioutput/conditionals.py#L363-L445 | [
"def",
"fully_correlated_conditional_repeat",
"(",
"Kmn",
",",
"Kmm",
",",
"Knn",
",",
"f",
",",
"*",
",",
"full_cov",
"=",
"False",
",",
"full_output_cov",
"=",
"False",
",",
"q_sqrt",
"=",
"None",
",",
"white",
"=",
"False",
")",
":",
"logger",
".",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | _mix_latent_gp | r"""
Takes the mean and variance of an uncorrelated L-dimensional latent GP
and returns the mean and the variance of the mixed GP, `f = W g`,
where both f and g are GPs, with W having a shape [P, L]
:param W: [P, L]
:param g_mu: [..., N, L]
:param g_var: [..., N, L] (full_cov = False) or [L, ..... | gpflow/multioutput/conditionals.py | def _mix_latent_gp(W, g_mu, g_var, full_cov, full_output_cov):
r"""
Takes the mean and variance of an uncorrelated L-dimensional latent GP
and returns the mean and the variance of the mixed GP, `f = W g`,
where both f and g are GPs, with W having a shape [P, L]
:param W: [P, L]
:param g_mu: [..... | def _mix_latent_gp(W, g_mu, g_var, full_cov, full_output_cov):
r"""
Takes the mean and variance of an uncorrelated L-dimensional latent GP
and returns the mean and the variance of the mixed GP, `f = W g`,
where both f and g are GPs, with W having a shape [P, L]
:param W: [P, L]
:param g_mu: [..... | [
"r",
"Takes",
"the",
"mean",
"and",
"variance",
"of",
"an",
"uncorrelated",
"L",
"-",
"dimensional",
"latent",
"GP",
"and",
"returns",
"the",
"mean",
"and",
"the",
"variance",
"of",
"the",
"mixed",
"GP",
"f",
"=",
"W",
"g",
"where",
"both",
"f",
"and",... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/multioutput/conditionals.py#L452-L490 | [
"def",
"_mix_latent_gp",
"(",
"W",
",",
"g_mu",
",",
"g_var",
",",
"full_cov",
",",
"full_output_cov",
")",
":",
"f_mu",
"=",
"tf",
".",
"tensordot",
"(",
"g_mu",
",",
"W",
",",
"[",
"[",
"-",
"1",
"]",
",",
"[",
"-",
"1",
"]",
"]",
")",
"# [..... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Parameter.size | The size of this parameter, equivalent to self.value.size | gpflow/params/parameter.py | def size(self):
"""The size of this parameter, equivalent to self.value.size"""
return np.multiply.reduce(self.shape, dtype=np.int32) | def size(self):
"""The size of this parameter, equivalent to self.value.size"""
return np.multiply.reduce(self.shape, dtype=np.int32) | [
"The",
"size",
"of",
"this",
"parameter",
"equivalent",
"to",
"self",
".",
"value",
".",
"size"
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/params/parameter.py#L158-L160 | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"np",
".",
"multiply",
".",
"reduce",
"(",
"self",
".",
"shape",
",",
"dtype",
"=",
"np",
".",
"int32",
")"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Parameter.tf_compilation_index | Takes out index from the parameter's tensor name. E.g. parameter tensor name is
GPR-0000/kern/lengthscales, the method for that parameter will return '0000' index. | gpflow/params/parameter.py | def tf_compilation_index(self):
"""
Takes out index from the parameter's tensor name. E.g. parameter tensor name is
GPR-0000/kern/lengthscales, the method for that parameter will return '0000' index.
"""
if self.parameter_tensor is None:
return None
name = se... | def tf_compilation_index(self):
"""
Takes out index from the parameter's tensor name. E.g. parameter tensor name is
GPR-0000/kern/lengthscales, the method for that parameter will return '0000' index.
"""
if self.parameter_tensor is None:
return None
name = se... | [
"Takes",
"out",
"index",
"from",
"the",
"parameter",
"s",
"tensor",
"name",
".",
"E",
".",
"g",
".",
"parameter",
"tensor",
"name",
"is",
"GPR",
"-",
"0000",
"/",
"kern",
"/",
"lengthscales",
"the",
"method",
"for",
"that",
"parameter",
"will",
"return",... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/params/parameter.py#L309-L317 | [
"def",
"tf_compilation_index",
"(",
"self",
")",
":",
"if",
"self",
".",
"parameter_tensor",
"is",
"None",
":",
"return",
"None",
"name",
"=",
"self",
".",
"parameter_tensor",
".",
"name",
"return",
"name",
".",
"split",
"(",
"'-'",
",",
"1",
")",
"[",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Parameter._build_prior | Build a tensorflow representation of the prior density.
The log Jacobian is included. | gpflow/params/parameter.py | def _build_prior(self, unconstrained_tensor, constrained_tensor):
"""
Build a tensorflow representation of the prior density.
The log Jacobian is included.
"""
if not misc.is_tensor(unconstrained_tensor):
raise GPflowError("Unconstrained input must be a tensor.")
... | def _build_prior(self, unconstrained_tensor, constrained_tensor):
"""
Build a tensorflow representation of the prior density.
The log Jacobian is included.
"""
if not misc.is_tensor(unconstrained_tensor):
raise GPflowError("Unconstrained input must be a tensor.")
... | [
"Build",
"a",
"tensorflow",
"representation",
"of",
"the",
"prior",
"density",
".",
"The",
"log",
"Jacobian",
"is",
"included",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/params/parameter.py#L403-L421 | [
"def",
"_build_prior",
"(",
"self",
",",
"unconstrained_tensor",
",",
"constrained_tensor",
")",
":",
"if",
"not",
"misc",
".",
"is_tensor",
"(",
"unconstrained_tensor",
")",
":",
"raise",
"GPflowError",
"(",
"\"Unconstrained input must be a tensor.\"",
")",
"if",
"... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | ExternalOptimizerInterface.minimize | Minimize a scalar `Tensor`.
Variables subject to optimization are updated in-place at the end of
optimization.
Note that this method does *not* just return a minimization `Op`, unlike
`Optimizer.minimize()`; instead it actually performs minimization by
executing commands to control a `Session`.
... | gpflow/training/external_optimizer.py | def minimize(self,
session=None,
feed_dict=None,
fetches=None,
step_callback=None,
loss_callback=None,
**run_kwargs):
"""Minimize a scalar `Tensor`.
Variables subject to optimization are updated in-place at the end of
... | def minimize(self,
session=None,
feed_dict=None,
fetches=None,
step_callback=None,
loss_callback=None,
**run_kwargs):
"""Minimize a scalar `Tensor`.
Variables subject to optimization are updated in-place at the end of
... | [
"Minimize",
"a",
"scalar",
"Tensor",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/external_optimizer.py#L108-L184 | [
"def",
"minimize",
"(",
"self",
",",
"session",
"=",
"None",
",",
"feed_dict",
"=",
"None",
",",
"fetches",
"=",
"None",
",",
"step_callback",
"=",
"None",
",",
"loss_callback",
"=",
"None",
",",
"*",
"*",
"run_kwargs",
")",
":",
"session",
"=",
"sessi... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | ExternalOptimizerInterface._minimize | Wrapper for a particular optimization algorithm implementation.
It would be appropriate for a subclass implementation of this method to
raise `NotImplementedError` if unsupported arguments are passed: e.g. if an
algorithm does not support constraints but `len(equality_funcs) > 0`.
Args:
initial_... | gpflow/training/external_optimizer.py | def _minimize(self, initial_val, loss_grad_func, equality_funcs,
equality_grad_funcs, inequality_funcs, inequality_grad_funcs,
packed_bounds, step_callback, optimizer_kwargs):
"""Wrapper for a particular optimization algorithm implementation.
It would be appropriate for a subcla... | def _minimize(self, initial_val, loss_grad_func, equality_funcs,
equality_grad_funcs, inequality_funcs, inequality_grad_funcs,
packed_bounds, step_callback, optimizer_kwargs):
"""Wrapper for a particular optimization algorithm implementation.
It would be appropriate for a subcla... | [
"Wrapper",
"for",
"a",
"particular",
"optimization",
"algorithm",
"implementation",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/external_optimizer.py#L248-L278 | [
"def",
"_minimize",
"(",
"self",
",",
"initial_val",
",",
"loss_grad_func",
",",
"equality_funcs",
",",
"equality_grad_funcs",
",",
"inequality_funcs",
",",
"inequality_grad_funcs",
",",
"packed_bounds",
",",
"step_callback",
",",
"optimizer_kwargs",
")",
":",
"raise"... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | ExternalOptimizerInterface._pack | Pack a list of `Tensor`s into a single, flattened, rank-1 `Tensor`. | gpflow/training/external_optimizer.py | def _pack(cls, tensors):
"""Pack a list of `Tensor`s into a single, flattened, rank-1 `Tensor`."""
if not tensors:
return None
elif len(tensors) == 1:
return array_ops.reshape(tensors[0], [-1])
else:
flattened = [array_ops.reshape(tensor, [-1]) for tensor in tensors]
return array... | def _pack(cls, tensors):
"""Pack a list of `Tensor`s into a single, flattened, rank-1 `Tensor`."""
if not tensors:
return None
elif len(tensors) == 1:
return array_ops.reshape(tensors[0], [-1])
else:
flattened = [array_ops.reshape(tensor, [-1]) for tensor in tensors]
return array... | [
"Pack",
"a",
"list",
"of",
"Tensor",
"s",
"into",
"a",
"single",
"flattened",
"rank",
"-",
"1",
"Tensor",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/external_optimizer.py#L281-L289 | [
"def",
"_pack",
"(",
"cls",
",",
"tensors",
")",
":",
"if",
"not",
"tensors",
":",
"return",
"None",
"elif",
"len",
"(",
"tensors",
")",
"==",
"1",
":",
"return",
"array_ops",
".",
"reshape",
"(",
"tensors",
"[",
"0",
"]",
",",
"[",
"-",
"1",
"]"... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | ExternalOptimizerInterface._make_eval_func | Construct a function that evaluates a `Tensor` or list of `Tensor`s. | gpflow/training/external_optimizer.py | def _make_eval_func(self, tensors, session, feed_dict, fetches,
callback=None):
"""Construct a function that evaluates a `Tensor` or list of `Tensor`s."""
if not isinstance(tensors, list):
tensors = [tensors]
num_tensors = len(tensors)
def eval_func(x):
"""Function to ... | def _make_eval_func(self, tensors, session, feed_dict, fetches,
callback=None):
"""Construct a function that evaluates a `Tensor` or list of `Tensor`s."""
if not isinstance(tensors, list):
tensors = [tensors]
num_tensors = len(tensors)
def eval_func(x):
"""Function to ... | [
"Construct",
"a",
"function",
"that",
"evaluates",
"a",
"Tensor",
"or",
"list",
"of",
"Tensor",
"s",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/external_optimizer.py#L291-L316 | [
"def",
"_make_eval_func",
"(",
"self",
",",
"tensors",
",",
"session",
",",
"feed_dict",
",",
"fetches",
",",
"callback",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"tensors",
",",
"list",
")",
":",
"tensors",
"=",
"[",
"tensors",
"]",
"num... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | create_global_step | Creates the Tensorflow 'global_step' variable (see `MonitorContext.global_step_tensor`).
:param session: Tensorflow session the optimiser is running in
:return: The variable tensor. | gpflow/training/monitor.py | def create_global_step(session: tf.Session) -> tf.Variable:
"""
Creates the Tensorflow 'global_step' variable (see `MonitorContext.global_step_tensor`).
:param session: Tensorflow session the optimiser is running in
:return: The variable tensor.
"""
global_step_tensor = tf.Variable(0, trainable=... | def create_global_step(session: tf.Session) -> tf.Variable:
"""
Creates the Tensorflow 'global_step' variable (see `MonitorContext.global_step_tensor`).
:param session: Tensorflow session the optimiser is running in
:return: The variable tensor.
"""
global_step_tensor = tf.Variable(0, trainable=... | [
"Creates",
"the",
"Tensorflow",
"global_step",
"variable",
"(",
"see",
"MonitorContext",
".",
"global_step_tensor",
")",
".",
":",
"param",
"session",
":",
"Tensorflow",
"session",
"the",
"optimiser",
"is",
"running",
"in",
":",
"return",
":",
"The",
"variable",... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L131-L139 | [
"def",
"create_global_step",
"(",
"session",
":",
"tf",
".",
"Session",
")",
"->",
"tf",
".",
"Variable",
":",
"global_step_tensor",
"=",
"tf",
".",
"Variable",
"(",
"0",
",",
"trainable",
"=",
"False",
",",
"name",
"=",
"\"global_step\"",
")",
"session",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | restore_session | Restores Tensorflow session from the latest checkpoint.
:param session: The TF session
:param checkpoint_dir: checkpoint files directory.
:param saver: The saver object, if not provided a default saver object will be created. | gpflow/training/monitor.py | def restore_session(session: tf.Session, checkpoint_dir: str,
saver: Optional[tf.train.Saver] = None) -> None:
"""
Restores Tensorflow session from the latest checkpoint.
:param session: The TF session
:param checkpoint_dir: checkpoint files directory.
:param saver: The saver obj... | def restore_session(session: tf.Session, checkpoint_dir: str,
saver: Optional[tf.train.Saver] = None) -> None:
"""
Restores Tensorflow session from the latest checkpoint.
:param session: The TF session
:param checkpoint_dir: checkpoint files directory.
:param saver: The saver obj... | [
"Restores",
"Tensorflow",
"session",
"from",
"the",
"latest",
"checkpoint",
".",
":",
"param",
"session",
":",
"The",
"TF",
"session",
":",
"param",
"checkpoint_dir",
":",
"checkpoint",
"files",
"directory",
".",
":",
"param",
"saver",
":",
"The",
"saver",
"... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L142-L156 | [
"def",
"restore_session",
"(",
"session",
":",
"tf",
".",
"Session",
",",
"checkpoint_dir",
":",
"str",
",",
"saver",
":",
"Optional",
"[",
"tf",
".",
"train",
".",
"Saver",
"]",
"=",
"None",
")",
"->",
"None",
":",
"checkpoint_path",
"=",
"tf",
".",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | get_default_saver | Creates Tensorflow Saver object with 3 recent checkpoints to keep.
:param max_to_keep: Maximum number of recent checkpoints to keep, defaults to 3 | gpflow/training/monitor.py | def get_default_saver(max_to_keep: int=3) -> tf.train.Saver:
"""
Creates Tensorflow Saver object with 3 recent checkpoints to keep.
:param max_to_keep: Maximum number of recent checkpoints to keep, defaults to 3
"""
return tf.train.Saver(max_to_keep=max_to_keep) | def get_default_saver(max_to_keep: int=3) -> tf.train.Saver:
"""
Creates Tensorflow Saver object with 3 recent checkpoints to keep.
:param max_to_keep: Maximum number of recent checkpoints to keep, defaults to 3
"""
return tf.train.Saver(max_to_keep=max_to_keep) | [
"Creates",
"Tensorflow",
"Saver",
"object",
"with",
"3",
"recent",
"checkpoints",
"to",
"keep",
".",
":",
"param",
"max_to_keep",
":",
"Maximum",
"number",
"of",
"recent",
"checkpoints",
"to",
"keep",
"defaults",
"to",
"3"
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L159-L164 | [
"def",
"get_default_saver",
"(",
"max_to_keep",
":",
"int",
"=",
"3",
")",
"->",
"tf",
".",
"train",
".",
"Saver",
":",
"return",
"tf",
".",
"train",
".",
"Saver",
"(",
"max_to_keep",
"=",
"max_to_keep",
")"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | update_optimiser | Writes optimiser state into corresponding TensorFlow variables. This may need to be done
for optimisers like ScipyOptimiser that work with their own copies of the variables.
Normally the source variables would be updated only when the optimiser has finished the
minimisation. This function may be called from... | gpflow/training/monitor.py | def update_optimiser(context, *args, **kwargs) -> None:
"""
Writes optimiser state into corresponding TensorFlow variables. This may need to be done
for optimisers like ScipyOptimiser that work with their own copies of the variables.
Normally the source variables would be updated only when the optimiser... | def update_optimiser(context, *args, **kwargs) -> None:
"""
Writes optimiser state into corresponding TensorFlow variables. This may need to be done
for optimisers like ScipyOptimiser that work with their own copies of the variables.
Normally the source variables would be updated only when the optimiser... | [
"Writes",
"optimiser",
"state",
"into",
"corresponding",
"TensorFlow",
"variables",
".",
"This",
"may",
"need",
"to",
"be",
"done",
"for",
"optimisers",
"like",
"ScipyOptimiser",
"that",
"work",
"with",
"their",
"own",
"copies",
"of",
"the",
"variables",
".",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L167-L195 | [
"def",
"update_optimiser",
"(",
"context",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"if",
"context",
".",
"optimiser",
"is",
"None",
"or",
"context",
".",
"optimiser_updated",
":",
"return",
"if",
"isinstance",
"(",
"context",
"... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | MonitorContext.global_step | Evaluates the value of the global step variable if it is set, otherwise returns the
current iteration number. | gpflow/training/monitor.py | def global_step(self) -> int:
"""
Evaluates the value of the global step variable if it is set, otherwise returns the
current iteration number.
"""
if self.session is None or self.global_step_tensor is None:
return self.iteration_no + self.init_global_step
els... | def global_step(self) -> int:
"""
Evaluates the value of the global step variable if it is set, otherwise returns the
current iteration number.
"""
if self.session is None or self.global_step_tensor is None:
return self.iteration_no + self.init_global_step
els... | [
"Evaluates",
"the",
"value",
"of",
"the",
"global",
"step",
"variable",
"if",
"it",
"is",
"set",
"otherwise",
"returns",
"the",
"current",
"iteration",
"number",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L238-L246 | [
"def",
"global_step",
"(",
"self",
")",
"->",
"int",
":",
"if",
"self",
".",
"session",
"is",
"None",
"or",
"self",
".",
"global_step_tensor",
"is",
"None",
":",
"return",
"self",
".",
"iteration_no",
"+",
"self",
".",
"init_global_step",
"else",
":",
"r... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | MonitorTask.with_condition | Sets the task running condition that will be evaluated during the optimisation cycle. | gpflow/training/monitor.py | def with_condition(self, condition: Callable[[MonitorContext], bool]) -> 'MonitorTask':
"""
Sets the task running condition that will be evaluated during the optimisation cycle.
"""
self._condition = condition
return self | def with_condition(self, condition: Callable[[MonitorContext], bool]) -> 'MonitorTask':
"""
Sets the task running condition that will be evaluated during the optimisation cycle.
"""
self._condition = condition
return self | [
"Sets",
"the",
"task",
"running",
"condition",
"that",
"will",
"be",
"evaluated",
"during",
"the",
"optimisation",
"cycle",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L280-L285 | [
"def",
"with_condition",
"(",
"self",
",",
"condition",
":",
"Callable",
"[",
"[",
"MonitorContext",
"]",
",",
"bool",
"]",
")",
"->",
"'MonitorTask'",
":",
"self",
".",
"_condition",
"=",
"condition",
"return",
"self"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | MonitorTask.with_exit_condition | Sets the flag indicating that the task should also run after the optimisation is ended. | gpflow/training/monitor.py | def with_exit_condition(self, exit_condition: Optional[bool]=True) -> 'MonitorTask':
"""
Sets the flag indicating that the task should also run after the optimisation is ended.
"""
self._exit_condition = exit_condition
return self | def with_exit_condition(self, exit_condition: Optional[bool]=True) -> 'MonitorTask':
"""
Sets the flag indicating that the task should also run after the optimisation is ended.
"""
self._exit_condition = exit_condition
return self | [
"Sets",
"the",
"flag",
"indicating",
"that",
"the",
"task",
"should",
"also",
"run",
"after",
"the",
"optimisation",
"is",
"ended",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L287-L292 | [
"def",
"with_exit_condition",
"(",
"self",
",",
"exit_condition",
":",
"Optional",
"[",
"bool",
"]",
"=",
"True",
")",
"->",
"'MonitorTask'",
":",
"self",
".",
"_exit_condition",
"=",
"exit_condition",
"return",
"self"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Monitor.start_monitoring | The recommended way of using Monitor is opening it with the `with` statement. In this case
the user doesn't need to call this function explicitly. Otherwise, the function should be
called before starting the optimiser.
The function evaluates the global_step variable in order to get its initial ... | gpflow/training/monitor.py | def start_monitoring(self) -> None:
"""
The recommended way of using Monitor is opening it with the `with` statement. In this case
the user doesn't need to call this function explicitly. Otherwise, the function should be
called before starting the optimiser.
The function evaluat... | def start_monitoring(self) -> None:
"""
The recommended way of using Monitor is opening it with the `with` statement. In this case
the user doesn't need to call this function explicitly. Otherwise, the function should be
called before starting the optimiser.
The function evaluat... | [
"The",
"recommended",
"way",
"of",
"using",
"Monitor",
"is",
"opening",
"it",
"with",
"the",
"with",
"statement",
".",
"In",
"this",
"case",
"the",
"user",
"doesn",
"t",
"need",
"to",
"call",
"this",
"function",
"explicitly",
".",
"Otherwise",
"the",
"func... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L405-L416 | [
"def",
"start_monitoring",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_context",
".",
"init_global_step",
"=",
"self",
".",
"_context",
".",
"global_step",
"self",
".",
"_start_timestamp",
"=",
"get_hr_time",
"(",
")",
"self",
".",
"_last_timestamp",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Monitor.stop_monitoring | The recommended way of using Monitor is opening it with the `with` statement. In this case
the user doesn't need to call this function explicitly. Otherwise the function should be
called when the optimisation is done.
The function sets the optimisation completed flag in the monitoring context a... | gpflow/training/monitor.py | def stop_monitoring(self) -> None:
"""
The recommended way of using Monitor is opening it with the `with` statement. In this case
the user doesn't need to call this function explicitly. Otherwise the function should be
called when the optimisation is done.
The function sets the ... | def stop_monitoring(self) -> None:
"""
The recommended way of using Monitor is opening it with the `with` statement. In this case
the user doesn't need to call this function explicitly. Otherwise the function should be
called when the optimisation is done.
The function sets the ... | [
"The",
"recommended",
"way",
"of",
"using",
"Monitor",
"is",
"opening",
"it",
"with",
"the",
"with",
"statement",
".",
"In",
"this",
"case",
"the",
"user",
"doesn",
"t",
"need",
"to",
"call",
"this",
"function",
"explicitly",
".",
"Otherwise",
"the",
"func... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L418-L433 | [
"def",
"stop_monitoring",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_context",
".",
"optimisation_finished",
"=",
"True",
"self",
".",
"_on_iteration",
"(",
")",
"if",
"self",
".",
"_print_summary",
":",
"self",
".",
"print_summary",
"(",
")"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Monitor.print_summary | Prints the tasks' timing summary. | gpflow/training/monitor.py | def print_summary(self) -> None:
"""
Prints the tasks' timing summary.
"""
print("Tasks execution time summary:")
for mon_task in self._monitor_tasks:
print("%s:\t%.4f (sec)" % (mon_task.task_name, mon_task.total_time)) | def print_summary(self) -> None:
"""
Prints the tasks' timing summary.
"""
print("Tasks execution time summary:")
for mon_task in self._monitor_tasks:
print("%s:\t%.4f (sec)" % (mon_task.task_name, mon_task.total_time)) | [
"Prints",
"the",
"tasks",
"timing",
"summary",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L435-L441 | [
"def",
"print_summary",
"(",
"self",
")",
"->",
"None",
":",
"print",
"(",
"\"Tasks execution time summary:\"",
")",
"for",
"mon_task",
"in",
"self",
".",
"_monitor_tasks",
":",
"print",
"(",
"\"%s:\\t%.4f (sec)\"",
"%",
"(",
"mon_task",
".",
"task_name",
",",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Monitor._on_iteration | Called at each iteration.
This function does time measurements, updates timing in the monitoring context and calls
all monitoring tasks. | gpflow/training/monitor.py | def _on_iteration(self, *args, **kwargs) -> None:
"""
Called at each iteration.
This function does time measurements, updates timing in the monitoring context and calls
all monitoring tasks.
"""
# Update timing and the iteration number in the monitoring context.
... | def _on_iteration(self, *args, **kwargs) -> None:
"""
Called at each iteration.
This function does time measurements, updates timing in the monitoring context and calls
all monitoring tasks.
"""
# Update timing and the iteration number in the monitoring context.
... | [
"Called",
"at",
"each",
"iteration",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L443-L465 | [
"def",
"_on_iteration",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"# Update timing and the iteration number in the monitoring context.",
"current_timestamp",
"=",
"get_hr_time",
"(",
")",
"self",
".",
"_context",
".",
"optimisat... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | GrowingIntervalCondition._growing_step_sequence | Returns an iterator that constructs a sequence of trigger levels with growing intervals.
The interval is growing exponentially until it reaches the maximum value. Then the interval
stays the same and the sequence becomes linear.
An optional starting level `start_level` defaults to the initial i... | gpflow/training/monitor.py | def _growing_step_sequence(interval_growth, max_interval, init_interval, start_level=None):
"""
Returns an iterator that constructs a sequence of trigger levels with growing intervals.
The interval is growing exponentially until it reaches the maximum value. Then the interval
stays the s... | def _growing_step_sequence(interval_growth, max_interval, init_interval, start_level=None):
"""
Returns an iterator that constructs a sequence of trigger levels with growing intervals.
The interval is growing exponentially until it reaches the maximum value. Then the interval
stays the s... | [
"Returns",
"an",
"iterator",
"that",
"constructs",
"a",
"sequence",
"of",
"trigger",
"levels",
"with",
"growing",
"intervals",
".",
"The",
"interval",
"is",
"growing",
"exponentially",
"until",
"it",
"reaches",
"the",
"maximum",
"value",
".",
"Then",
"the",
"i... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L550-L565 | [
"def",
"_growing_step_sequence",
"(",
"interval_growth",
",",
"max_interval",
",",
"init_interval",
",",
"start_level",
"=",
"None",
")",
":",
"interval",
"=",
"init_interval",
"next_level",
"=",
"start_level",
"or",
"init_interval",
"while",
"True",
":",
"yield",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | LogdirWriter.__lock_location | Attempts to lock the location used by this writer. Will raise an error if the location is
already locked by another writer. Will do nothing if the location is already locked by
this writer. | gpflow/training/monitor.py | def __lock_location(self) -> None:
"""
Attempts to lock the location used by this writer. Will raise an error if the location is
already locked by another writer. Will do nothing if the location is already locked by
this writer.
"""
if not self._is_active:
if ... | def __lock_location(self) -> None:
"""
Attempts to lock the location used by this writer. Will raise an error if the location is
already locked by another writer. Will do nothing if the location is already locked by
this writer.
"""
if not self._is_active:
if ... | [
"Attempts",
"to",
"lock",
"the",
"location",
"used",
"by",
"this",
"writer",
".",
"Will",
"raise",
"an",
"error",
"if",
"the",
"location",
"is",
"already",
"locked",
"by",
"another",
"writer",
".",
"Will",
"do",
"nothing",
"if",
"the",
"location",
"is",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L758-L770 | [
"def",
"__lock_location",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"_is_active",
":",
"if",
"self",
".",
"_location",
"in",
"LogdirWriter",
".",
"_locked_locations",
":",
"raise",
"RuntimeError",
"(",
"'TensorBoard event file in directory %s ... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | LogdirWriter.__release_location | Releases the lock on the location used by this writer. Will do nothing if the lock is
already released. | gpflow/training/monitor.py | def __release_location(self) -> None:
"""
Releases the lock on the location used by this writer. Will do nothing if the lock is
already released.
"""
if self._is_active:
LogdirWriter._locked_locations.remove(self._location)
self._is_active = False | def __release_location(self) -> None:
"""
Releases the lock on the location used by this writer. Will do nothing if the lock is
already released.
"""
if self._is_active:
LogdirWriter._locked_locations.remove(self._location)
self._is_active = False | [
"Releases",
"the",
"lock",
"on",
"the",
"location",
"used",
"by",
"this",
"writer",
".",
"Will",
"do",
"nothing",
"if",
"the",
"lock",
"is",
"already",
"released",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L772-L779 | [
"def",
"__release_location",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"_is_active",
":",
"LogdirWriter",
".",
"_locked_locations",
".",
"remove",
"(",
"self",
".",
"_location",
")",
"self",
".",
"_is_active",
"=",
"False"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | BaseTensorBoardTask.with_flush_immediately | Sets the flag indicating that the event file should be flushed at each call. | gpflow/training/monitor.py | def with_flush_immediately(self, flush_immediately: Optional[bool]=True)\
-> 'BaseTensorBoardTask':
"""
Sets the flag indicating that the event file should be flushed at each call.
"""
self._flush_immediately = flush_immediately
return self | def with_flush_immediately(self, flush_immediately: Optional[bool]=True)\
-> 'BaseTensorBoardTask':
"""
Sets the flag indicating that the event file should be flushed at each call.
"""
self._flush_immediately = flush_immediately
return self | [
"Sets",
"the",
"flag",
"indicating",
"that",
"the",
"event",
"file",
"should",
"be",
"flushed",
"at",
"each",
"call",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L821-L827 | [
"def",
"with_flush_immediately",
"(",
"self",
",",
"flush_immediately",
":",
"Optional",
"[",
"bool",
"]",
"=",
"True",
")",
"->",
"'BaseTensorBoardTask'",
":",
"self",
".",
"_flush_immediately",
"=",
"flush_immediately",
"return",
"self"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | BaseTensorBoardTask._eval_summary | Evaluates the summary tensor and writes the result to the event file.
:param context: Monitor context
:param feed_dict: Input values dictionary to be provided to the `session.run`
when evaluating the summary tensor. | gpflow/training/monitor.py | def _eval_summary(self, context: MonitorContext, feed_dict: Optional[Dict]=None) -> None:
"""
Evaluates the summary tensor and writes the result to the event file.
:param context: Monitor context
:param feed_dict: Input values dictionary to be provided to the `session.run`
when e... | def _eval_summary(self, context: MonitorContext, feed_dict: Optional[Dict]=None) -> None:
"""
Evaluates the summary tensor and writes the result to the event file.
:param context: Monitor context
:param feed_dict: Input values dictionary to be provided to the `session.run`
when e... | [
"Evaluates",
"the",
"summary",
"tensor",
"and",
"writes",
"the",
"result",
"to",
"the",
"event",
"file",
".",
":",
"param",
"context",
":",
"Monitor",
"context",
":",
"param",
"feed_dict",
":",
"Input",
"values",
"dictionary",
"to",
"be",
"provided",
"to",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/training/monitor.py#L836-L854 | [
"def",
"_eval_summary",
"(",
"self",
",",
"context",
":",
"MonitorContext",
",",
"feed_dict",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
")",
"->",
"None",
":",
"if",
"self",
".",
"_summary",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Tensor... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | make_grid | Returns two n-by-n matrices. The first one contains all the x values
and the second all the y values of a cartesian product between `xx` and `yy`. | doc/source/notebooks/tailor/mdn_plotting.py | def make_grid(xx, yy):
"""
Returns two n-by-n matrices. The first one contains all the x values
and the second all the y values of a cartesian product between `xx` and `yy`.
"""
n = len(xx)
xx, yy = np.meshgrid(xx, yy)
grid = np.array([xx.ravel(), yy.ravel()]).T
x = grid[:, 0].reshape(n... | def make_grid(xx, yy):
"""
Returns two n-by-n matrices. The first one contains all the x values
and the second all the y values of a cartesian product between `xx` and `yy`.
"""
n = len(xx)
xx, yy = np.meshgrid(xx, yy)
grid = np.array([xx.ravel(), yy.ravel()]).T
x = grid[:, 0].reshape(n... | [
"Returns",
"two",
"n",
"-",
"by",
"-",
"n",
"matrices",
".",
"The",
"first",
"one",
"contains",
"all",
"the",
"x",
"values",
"and",
"the",
"second",
"all",
"the",
"y",
"values",
"of",
"a",
"cartesian",
"product",
"between",
"xx",
"and",
"yy",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/doc/source/notebooks/tailor/mdn_plotting.py#L6-L16 | [
"def",
"make_grid",
"(",
"xx",
",",
"yy",
")",
":",
"n",
"=",
"len",
"(",
"xx",
")",
"xx",
",",
"yy",
"=",
"np",
".",
"meshgrid",
"(",
"xx",
",",
"yy",
")",
"grid",
"=",
"np",
".",
"array",
"(",
"[",
"xx",
".",
"ravel",
"(",
")",
",",
"yy... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Watcher.elapsed | Elapsed time [µs] between start and stop timestamps. If stop is empty then
returned time is difference between start and current timestamp. | gpflow/actions.py | def elapsed(self):
"""
Elapsed time [µs] between start and stop timestamps. If stop is empty then
returned time is difference between start and current timestamp.
"""
if self._stop is None:
return timer() - self._start
return self._stop - self._start | def elapsed(self):
"""
Elapsed time [µs] between start and stop timestamps. If stop is empty then
returned time is difference between start and current timestamp.
"""
if self._stop is None:
return timer() - self._start
return self._stop - self._start | [
"Elapsed",
"time",
"[",
"µs",
"]",
"between",
"start",
"and",
"stop",
"timestamps",
".",
"If",
"stop",
"is",
"empty",
"then",
"returned",
"time",
"is",
"difference",
"between",
"start",
"and",
"current",
"timestamp",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/actions.py#L56-L63 | [
"def",
"elapsed",
"(",
"self",
")",
":",
"if",
"self",
".",
"_stop",
"is",
"None",
":",
"return",
"timer",
"(",
")",
"-",
"self",
".",
"_start",
"return",
"self",
".",
"_stop",
"-",
"self",
".",
"_start"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Action.watcher | Gives an access to action's watcher.
:return: Action's watcher instance. | gpflow/actions.py | def watcher(self) -> Watcher:
"""
Gives an access to action's watcher.
:return: Action's watcher instance.
"""
if not hasattr(self, "_watcher"):
self._watcher = Watcher()
return self._watcher | def watcher(self) -> Watcher:
"""
Gives an access to action's watcher.
:return: Action's watcher instance.
"""
if not hasattr(self, "_watcher"):
self._watcher = Watcher()
return self._watcher | [
"Gives",
"an",
"access",
"to",
"action",
"s",
"watcher",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/actions.py#L121-L129 | [
"def",
"watcher",
"(",
"self",
")",
"->",
"Watcher",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_watcher\"",
")",
":",
"self",
".",
"_watcher",
"=",
"Watcher",
"(",
")",
"return",
"self",
".",
"_watcher"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Loop.with_settings | Set start, stop and step loop configuration.
:param stop: Looop stop iteration integer. If None then loop
becomes infinite.
:param start: Loop iteration start integer.
:param step: Loop iteration interval integer.
:return: Loop itself. | gpflow/actions.py | def with_settings(self,
stop: Optional[int] = None,
start: int = 0,
step: int = 1) -> 'Loop':
"""
Set start, stop and step loop configuration.
:param stop: Looop stop iteration integer. If None then loop
becomes infinite.
:para... | def with_settings(self,
stop: Optional[int] = None,
start: int = 0,
step: int = 1) -> 'Loop':
"""
Set start, stop and step loop configuration.
:param stop: Looop stop iteration integer. If None then loop
becomes infinite.
:para... | [
"Set",
"start",
"stop",
"and",
"step",
"loop",
"configuration",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/actions.py#L211-L227 | [
"def",
"with_settings",
"(",
"self",
",",
"stop",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"start",
":",
"int",
"=",
"0",
",",
"step",
":",
"int",
"=",
"1",
")",
"->",
"'Loop'",
":",
"self",
".",
"start",
"=",
"start",
"self",
".",
"... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Loop.run | Run performs loop iterations.
:param context: Action context. | gpflow/actions.py | def run(self, context: ActionContext):
"""
Run performs loop iterations.
:param context: Action context.
"""
iterator = itertools.count(start=self.start, step=self.step)
for i in iterator:
self.with_iteration(i)
if self.stop is not None and i ... | def run(self, context: ActionContext):
"""
Run performs loop iterations.
:param context: Action context.
"""
iterator = itertools.count(start=self.start, step=self.step)
for i in iterator:
self.with_iteration(i)
if self.stop is not None and i ... | [
"Run",
"performs",
"loop",
"iterations",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/actions.py#L229-L245 | [
"def",
"run",
"(",
"self",
",",
"context",
":",
"ActionContext",
")",
":",
"iterator",
"=",
"itertools",
".",
"count",
"(",
"start",
"=",
"self",
".",
"start",
",",
"step",
"=",
"self",
".",
"step",
")",
"for",
"i",
"in",
"iterator",
":",
"self",
"... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Optimization.with_optimizer_tensor | Replace optimizer tensor.
:param model: Tensorflow tensor.
:return: Optimization instance self reference. | gpflow/actions.py | def with_optimizer_tensor(self, tensor: Union[tf.Tensor, tf.Operation]) -> 'Optimization':
"""
Replace optimizer tensor.
:param model: Tensorflow tensor.
:return: Optimization instance self reference.
"""
self._optimizer_tensor = tensor
return self | def with_optimizer_tensor(self, tensor: Union[tf.Tensor, tf.Operation]) -> 'Optimization':
"""
Replace optimizer tensor.
:param model: Tensorflow tensor.
:return: Optimization instance self reference.
"""
self._optimizer_tensor = tensor
return self | [
"Replace",
"optimizer",
"tensor",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/actions.py#L325-L333 | [
"def",
"with_optimizer_tensor",
"(",
"self",
",",
"tensor",
":",
"Union",
"[",
"tf",
".",
"Tensor",
",",
"tf",
".",
"Operation",
"]",
")",
"->",
"'Optimization'",
":",
"self",
".",
"_optimizer_tensor",
"=",
"tensor",
"return",
"self"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Optimization.with_run_kwargs | Replace Tensorflow session run kwargs.
Check Tensorflow session run [documentation](https://www.tensorflow.org/api_docs/python/tf/Session).
:param kwargs: Dictionary of tensors as keys and numpy arrays or
primitive python types as values.
:return: Optimization instance s... | gpflow/actions.py | def with_run_kwargs(self, **kwargs: Dict[str, Any]) -> 'Optimization':
"""
Replace Tensorflow session run kwargs.
Check Tensorflow session run [documentation](https://www.tensorflow.org/api_docs/python/tf/Session).
:param kwargs: Dictionary of tensors as keys and numpy arrays or
... | def with_run_kwargs(self, **kwargs: Dict[str, Any]) -> 'Optimization':
"""
Replace Tensorflow session run kwargs.
Check Tensorflow session run [documentation](https://www.tensorflow.org/api_docs/python/tf/Session).
:param kwargs: Dictionary of tensors as keys and numpy arrays or
... | [
"Replace",
"Tensorflow",
"session",
"run",
"kwargs",
".",
"Check",
"Tensorflow",
"session",
"run",
"[",
"documentation",
"]",
"(",
"https",
":",
"//",
"www",
".",
"tensorflow",
".",
"org",
"/",
"api_docs",
"/",
"python",
"/",
"tf",
"/",
"Session",
")",
"... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/actions.py#L335-L345 | [
"def",
"with_run_kwargs",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"'Optimization'",
":",
"self",
".",
"_run_kwargs",
"=",
"kwargs",
"return",
"self"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | Optimization.optimizer_tensor | The `optimizer_tensor` is an attribute for getting optimization's
optimizer tensor. | gpflow/actions.py | def optimizer_tensor(self) -> Union[tf.Tensor, tf.Operation]:
"""
The `optimizer_tensor` is an attribute for getting optimization's
optimizer tensor.
"""
return _get_attr(self, _optimizer_tensor=None) | def optimizer_tensor(self) -> Union[tf.Tensor, tf.Operation]:
"""
The `optimizer_tensor` is an attribute for getting optimization's
optimizer tensor.
"""
return _get_attr(self, _optimizer_tensor=None) | [
"The",
"optimizer_tensor",
"is",
"an",
"attribute",
"for",
"getting",
"optimization",
"s",
"optimizer",
"tensor",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/actions.py#L353-L358 | [
"def",
"optimizer_tensor",
"(",
"self",
")",
"->",
"Union",
"[",
"tf",
".",
"Tensor",
",",
"tf",
".",
"Operation",
"]",
":",
"return",
"_get_attr",
"(",
"self",
",",
"_optimizer_tensor",
"=",
"None",
")"
] | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | _conditional | Single-output GP conditional.
The covariance matrices used to calculate the conditional have the following shape:
- Kuu: M x M
- Kuf: M x N
- Kff: N or N x N
Further reference
-----------------
- See `gpflow.conditionals._conditional` (below) for a detailed explanation of
conditional... | gpflow/conditionals.py | def _conditional(Xnew, feat, kern, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False):
"""
Single-output GP conditional.
The covariance matrices used to calculate the conditional have the following shape:
- Kuu: M x M
- Kuf: M x N
- Kff: N or N x N
Further reference
... | def _conditional(Xnew, feat, kern, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False):
"""
Single-output GP conditional.
The covariance matrices used to calculate the conditional have the following shape:
- Kuu: M x M
- Kuf: M x N
- Kff: N or N x N
Further reference
... | [
"Single",
"-",
"output",
"GP",
"conditional",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/conditionals.py#L35-L75 | [
"def",
"_conditional",
"(",
"Xnew",
",",
"feat",
",",
"kern",
",",
"f",
",",
"*",
",",
"full_cov",
"=",
"False",
",",
"full_output_cov",
"=",
"False",
",",
"q_sqrt",
"=",
"None",
",",
"white",
"=",
"False",
")",
":",
"logger",
".",
"debug",
"(",
"\... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | _conditional | Given f, representing the GP at the points X, produce the mean and
(co-)variance of the GP at the points Xnew.
Additionally, there may be Gaussian uncertainty about f as represented by
q_sqrt. In this case `f` represents the mean of the distribution and
q_sqrt the square-root of the covariance.
Ad... | gpflow/conditionals.py | def _conditional(Xnew, X, kern, f, *, full_cov=False, q_sqrt=None, white=False, full_output_cov=None):
"""
Given f, representing the GP at the points X, produce the mean and
(co-)variance of the GP at the points Xnew.
Additionally, there may be Gaussian uncertainty about f as represented by
q_sqrt.... | def _conditional(Xnew, X, kern, f, *, full_cov=False, q_sqrt=None, white=False, full_output_cov=None):
"""
Given f, representing the GP at the points X, produce the mean and
(co-)variance of the GP at the points Xnew.
Additionally, there may be Gaussian uncertainty about f as represented by
q_sqrt.... | [
"Given",
"f",
"representing",
"the",
"GP",
"at",
"the",
"points",
"X",
"produce",
"the",
"mean",
"and",
"(",
"co",
"-",
")",
"variance",
"of",
"the",
"GP",
"at",
"the",
"points",
"Xnew",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/conditionals.py#L80-L127 | [
"def",
"_conditional",
"(",
"Xnew",
",",
"X",
",",
"kern",
",",
"f",
",",
"*",
",",
"full_cov",
"=",
"False",
",",
"q_sqrt",
"=",
"None",
",",
"white",
"=",
"False",
",",
"full_output_cov",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"Con... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | _sample_conditional | `sample_conditional` will return a sample from the conditional distribution.
In most cases this means calculating the conditional mean m and variance v and then
returning m + sqrt(v) * eps, with eps ~ N(0, 1).
However, for some combinations of Mok and Mof more efficient sampling routines exists.
The dis... | gpflow/conditionals.py | def _sample_conditional(Xnew, feat, kern, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False, num_samples=None):
"""
`sample_conditional` will return a sample from the conditional distribution.
In most cases this means calculating the conditional mean m and variance v and then
returni... | def _sample_conditional(Xnew, feat, kern, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False, num_samples=None):
"""
`sample_conditional` will return a sample from the conditional distribution.
In most cases this means calculating the conditional mean m and variance v and then
returni... | [
"sample_conditional",
"will",
"return",
"a",
"sample",
"from",
"the",
"conditional",
"distribution",
".",
"In",
"most",
"cases",
"this",
"means",
"calculating",
"the",
"conditional",
"mean",
"m",
"and",
"variance",
"v",
"and",
"then",
"returning",
"m",
"+",
"s... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/conditionals.py#L138-L170 | [
"def",
"_sample_conditional",
"(",
"Xnew",
",",
"feat",
",",
"kern",
",",
"f",
",",
"*",
",",
"full_cov",
"=",
"False",
",",
"full_output_cov",
"=",
"False",
",",
"q_sqrt",
"=",
"None",
",",
"white",
"=",
"False",
",",
"num_samples",
"=",
"None",
")",
... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | base_conditional | r"""
Given a g1 and g2, and distribution p and q such that
p(g2) = N(g2;0,Kmm)
p(g1) = N(g1;0,Knn)
p(g1|g2) = N(g1;0,Knm)
And
q(g2) = N(g2;f,q_sqrt*q_sqrt^T)
This method computes the mean and (co)variance of
q(g1) = \int q(g2) p(g1|g2)
:param Kmn: M x [...] x N
:param K... | gpflow/conditionals.py | def base_conditional(Kmn, Kmm, Knn, f, *, full_cov=False, q_sqrt=None, white=False):
r"""
Given a g1 and g2, and distribution p and q such that
p(g2) = N(g2;0,Kmm)
p(g1) = N(g1;0,Knn)
p(g1|g2) = N(g1;0,Knm)
And
q(g2) = N(g2;f,q_sqrt*q_sqrt^T)
This method computes the mean and (co... | def base_conditional(Kmn, Kmm, Knn, f, *, full_cov=False, q_sqrt=None, white=False):
r"""
Given a g1 and g2, and distribution p and q such that
p(g2) = N(g2;0,Kmm)
p(g1) = N(g1;0,Knn)
p(g1|g2) = N(g1;0,Knm)
And
q(g2) = N(g2;f,q_sqrt*q_sqrt^T)
This method computes the mean and (co... | [
"r",
"Given",
"a",
"g1",
"and",
"g2",
"and",
"distribution",
"p",
"and",
"q",
"such",
"that",
"p",
"(",
"g2",
")",
"=",
"N",
"(",
"g2",
";",
"0",
"Kmm",
")",
"p",
"(",
"g1",
")",
"=",
"N",
"(",
"g1",
";",
"0",
"Knn",
")",
"p",
"(",
"g1|g2... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/conditionals.py#L179-L258 | [
"def",
"base_conditional",
"(",
"Kmn",
",",
"Kmm",
",",
"Knn",
",",
"f",
",",
"*",
",",
"full_cov",
"=",
"False",
",",
"q_sqrt",
"=",
"None",
",",
"white",
"=",
"False",
")",
":",
"logger",
".",
"debug",
"(",
"\"base conditional\"",
")",
"# compute ker... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | uncertain_conditional | Calculates the conditional for uncertain inputs Xnew, p(Xnew) = N(Xnew_mu, Xnew_var).
See ``conditional`` documentation for further reference.
:param Xnew_mu: mean of the inputs, size N x Din
:param Xnew_var: covariance matrix of the inputs, size N x Din x Din
:param feat: gpflow.InducingFeature object... | gpflow/conditionals.py | def uncertain_conditional(Xnew_mu, Xnew_var, feat, kern, q_mu, q_sqrt, *,
mean_function=None, full_output_cov=False, full_cov=False, white=False):
"""
Calculates the conditional for uncertain inputs Xnew, p(Xnew) = N(Xnew_mu, Xnew_var).
See ``conditional`` documentation for further... | def uncertain_conditional(Xnew_mu, Xnew_var, feat, kern, q_mu, q_sqrt, *,
mean_function=None, full_output_cov=False, full_cov=False, white=False):
"""
Calculates the conditional for uncertain inputs Xnew, p(Xnew) = N(Xnew_mu, Xnew_var).
See ``conditional`` documentation for further... | [
"Calculates",
"the",
"conditional",
"for",
"uncertain",
"inputs",
"Xnew",
"p",
"(",
"Xnew",
")",
"=",
"N",
"(",
"Xnew_mu",
"Xnew_var",
")",
".",
"See",
"conditional",
"documentation",
"for",
"further",
"reference",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/conditionals.py#L265-L363 | [
"def",
"uncertain_conditional",
"(",
"Xnew_mu",
",",
"Xnew_var",
",",
"feat",
",",
"kern",
",",
"q_mu",
",",
"q_sqrt",
",",
"*",
",",
"mean_function",
"=",
"None",
",",
"full_output_cov",
"=",
"False",
",",
"full_cov",
"=",
"False",
",",
"white",
"=",
"F... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | _sample_mvn | Returns a sample from a D-dimensional Multivariate Normal distribution
:param mean: [..., N, D]
:param cov: [..., N, D] or [..., N, D, D]
:param cov_structure: "diag" or "full"
- "diag": cov holds the diagonal elements of the covariance matrix
- "full": cov holds the full covariance matrix (without ... | gpflow/conditionals.py | def _sample_mvn(mean, cov, cov_structure=None, num_samples=None):
"""
Returns a sample from a D-dimensional Multivariate Normal distribution
:param mean: [..., N, D]
:param cov: [..., N, D] or [..., N, D, D]
:param cov_structure: "diag" or "full"
- "diag": cov holds the diagonal elements of the ... | def _sample_mvn(mean, cov, cov_structure=None, num_samples=None):
"""
Returns a sample from a D-dimensional Multivariate Normal distribution
:param mean: [..., N, D]
:param cov: [..., N, D] or [..., N, D, D]
:param cov_structure: "diag" or "full"
- "diag": cov holds the diagonal elements of the ... | [
"Returns",
"a",
"sample",
"from",
"a",
"D",
"-",
"dimensional",
"Multivariate",
"Normal",
"distribution",
":",
"param",
"mean",
":",
"[",
"...",
"N",
"D",
"]",
":",
"param",
"cov",
":",
"[",
"...",
"N",
"D",
"]",
"or",
"[",
"...",
"N",
"D",
"D",
... | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/conditionals.py#L370-L409 | [
"def",
"_sample_mvn",
"(",
"mean",
",",
"cov",
",",
"cov_structure",
"=",
"None",
",",
"num_samples",
"=",
"None",
")",
":",
"mean_shape",
"=",
"tf",
".",
"shape",
"(",
"mean",
")",
"S",
"=",
"num_samples",
"if",
"num_samples",
"is",
"not",
"None",
"el... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
train | _expand_independent_outputs | Reshapes fvar to the correct shape, specified by `full_cov` and `full_output_cov`.
:param fvar: has shape N x P (full_cov = False) or P x N x N (full_cov = True).
:return:
1. full_cov: True and full_output_cov: True
fvar N x P x N x P
2. full_cov: True and full_output_cov: False
fvar P x ... | gpflow/conditionals.py | def _expand_independent_outputs(fvar, full_cov, full_output_cov):
"""
Reshapes fvar to the correct shape, specified by `full_cov` and `full_output_cov`.
:param fvar: has shape N x P (full_cov = False) or P x N x N (full_cov = True).
:return:
1. full_cov: True and full_output_cov: True
fvar N... | def _expand_independent_outputs(fvar, full_cov, full_output_cov):
"""
Reshapes fvar to the correct shape, specified by `full_cov` and `full_output_cov`.
:param fvar: has shape N x P (full_cov = False) or P x N x N (full_cov = True).
:return:
1. full_cov: True and full_output_cov: True
fvar N... | [
"Reshapes",
"fvar",
"to",
"the",
"correct",
"shape",
"specified",
"by",
"full_cov",
"and",
"full_output_cov",
"."
] | GPflow/GPflow | python | https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/conditionals.py#L412-L437 | [
"def",
"_expand_independent_outputs",
"(",
"fvar",
",",
"full_cov",
",",
"full_output_cov",
")",
":",
"if",
"full_cov",
"and",
"full_output_cov",
":",
"fvar",
"=",
"tf",
".",
"matrix_diag",
"(",
"tf",
".",
"transpose",
"(",
"fvar",
")",
")",
"# N x N x P x P",... | 549394f0b1b0696c7b521a065e49bdae6e7acf27 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.