-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Gauss-Legendre Quadrature Fourier features #64
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice PR - the code structure makes a lot of sense. I believe two things are missing right now:
- a README in the
fourier_features
directory outlining the different methods and in which scenarios they can be used. This can be very brief as long as it is practical. We could use tables or diagrams for this. - It looks like there are no tests for a few of the GaussianQuadrature features?
if tf.reduce_any(tf.less(kernel.lengthscales, 1e-1)): | ||
warnings.warn( | ||
"Quadrature Fourier feature approximation of kernels " | ||
"with small lengthscale lead to unexpected behaviors!" | ||
"Fourier feature approximation of kernels with small " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add what you mean by "small".
class QuadratureFourierFeatures(GaussHermiteQuadratureFourierFeatures): | ||
""" | ||
Alias for `GaussHermiteQuadratureFourierFeatures`. | ||
""" | ||
|
||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class QuadratureFourierFeatures(GaussHermiteQuadratureFourierFeatures): | |
""" | |
Alias for `GaussHermiteQuadratureFourierFeatures`. | |
""" | |
pass | |
QuadratureFourierFeatures = GaussHermiteQuadratureFourierFeatures | |
""" Alias for `GaussHermiteQuadratureFourierFeatures` """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe explain why we have this alias in place? Is this the most common and recommended quadrature rule?
def __init__(self, kernel: gpflow.kernels.Kernel, n_components: int, **kwargs: Mapping): | ||
""" | ||
:param kernel: kernel to approximate using a set of Fourier bases. | ||
:param n_components: number of components (e.g. Monte Carlo samples, | ||
quadrature nodes, etc.) used to numerically approximate the kernel. | ||
""" | ||
super(FourierFeaturesBase, self).__init__(**kwargs) | ||
assert isinstance( | ||
kernel, self.SUPPORTED_KERNELS | ||
), f"Only the following kernels are supported: {self.SUPPORTED_KERNELS}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: You could make this message more informative by specifying which kernel the user used.
|
||
def _compute_bases(self, inputs: TensorType) -> tf.Tensor: | ||
""" | ||
Compute basis functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: the word "compute" made me first think the function would return a functor with the basis functions.
Compute basis functions. | |
Evaluate the 2L^D number of basis functions at `inputs`. |
from gpflux.types import ShapeType | ||
|
||
|
||
class QuadratureFourierFeaturesBase(FourierFeaturesBase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please give a type and short description of self.factors
as it is being used in _compute_constant
.
class QuadratureFourierFeaturesBase(FourierFeaturesBase): | |
class QuadratureFourierFeaturesBase(FourierFeaturesBase): | |
factors: Type | |
"""Description""" |
|
||
|
||
class QuadratureFourierFeatures(FourierFeaturesBase): | ||
class GaussianQuadratureFourierFeatures(QuadratureFourierFeaturesBase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class GaussianQuadratureFourierFeatures(QuadratureFourierFeaturesBase): | |
class GaussianQuadratureFourierFeatures(QuadratureFourierFeaturesBase): | |
""" Base class for `GaussHermiteQuadratureFourierFeatures` and `GaussLegendreQuadratureFourierFeatures`. |
super(QuadratureFourierFeatures, self).__init__(kernel, n_components, **kwargs) | ||
|
||
|
||
class GaussHermiteQuadratureFourierFeatures(GaussianQuadratureFourierFeatures): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add a reference to which maths this class implements?
def _compute_bases(self, inputs: TensorType) -> tf.Tensor: | ||
""" | ||
Compute basis functions. | ||
class GaussLegendreQuadratureFourierFeatures(GaussianQuadratureFourierFeatures): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add a reference to which maths this class implements?
from gpflux.types import ShapeType | ||
|
||
|
||
class SimpsonQuadratureFourierFeatures(QuadratureFourierFeaturesBase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add a reference to which maths this class implements?
|
||
|
||
class QuasiRandomFourierFeatures(RandomFourierFeatures): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.