Feature request
It might be really nice to have the mean and variance returned by GPModel.predict_f and GPModel.predict_y to be typing.NamedTuples.
Motivation
This has two advantages. The main one is being able to calculate and use the mean or variance straightforwardly in one line, and in a clear, safe manner. Rather than
mean, _ = model.predict_f(...)
foo(mean)
which is a little verbose, or
foo(model.predict_f(...)[0])
which is prone to error and hard to read, you can do
foo(model.predict_f(...).mean)
The other advantage is that it's a little safer. Using res.mean is more explicit and less prone to error than res[0] or mean, _ = res.
Proposal
MeanAndVariance becomes a typing.NamedTuple like
class MeanAndVariance(NamedTuple):
mean: tf.Tensor
variance: tf.Tensor
Since NamedTuple is a typed version of namedtuple, which returns a subclass of tuple, I'm pretty sure this change is backwards compatible. Tests can be added to verify this
What alternatives have you considered?
None
Are you willing to open a pull request? (We really appreciate contributions!)
Maybe, not just now though
Feature request
It might be really nice to have the mean and variance returned by
GPModel.predict_fandGPModel.predict_yto betyping.NamedTuples.Motivation
This has two advantages. The main one is being able to calculate and use the mean or variance straightforwardly in one line, and in a clear, safe manner. Rather than
which is a little verbose, or
which is prone to error and hard to read, you can do
The other advantage is that it's a little safer. Using
res.meanis more explicit and less prone to error thanres[0]ormean, _ = res.Proposal
MeanAndVariancebecomes atyping.NamedTuplelikeSince
NamedTupleis a typed version ofnamedtuple, which returns a subclass oftuple, I'm pretty sure this change is backwards compatible. Tests can be added to verify thisWhat alternatives have you considered?
None
Are you willing to open a pull request? (We really appreciate contributions!)
Maybe, not just now though