Skip to content

Commit

Permalink
simplyfy function names and add author reference
Browse files Browse the repository at this point in the history
  • Loading branch information
juanitorduz committed May 6, 2024
1 parent 5f11d0e commit 2b1e37d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
21 changes: 11 additions & 10 deletions docs/source/contrib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ approximate Bayesian Gaussian processes for probabilistic programming. Stat Comp
5. `Gelman, Vehtari, Simpson, et al., Bayesian workflow book - Birthdays <https://avehtari.github.io/casestudies/Birthdays/birthdays.html>`_.

.. note::
The code of this module is based on the code of the example `Example: Hilbert space approximation for Gaussian processes <https://num.pyro.ai/en/stable/examples/hsgp.html>`_.
The code of this module is based on the code of the example
`Example: Hilbert space approximation for Gaussian processes <https://num.pyro.ai/en/stable/examples/hsgp.html>`_ by `Omar Sosa Rodríguez <https://github.com/omarfsosa>`_.

sqrt_eigenvalues
----------------
Expand Down Expand Up @@ -285,14 +286,14 @@ diag_spectral_density_periodic
------------------------------
.. autofunction:: numpyro.contrib.hsgp.spectral_densities.diag_spectral_density_periodic

hsgp_approximation_squared_exponential
--------------------------------------
.. autofunction:: numpyro.contrib.hsgp.approximation.hsgp_approximation_squared_exponential
hsgp_squared_exponential
------------------------
.. autofunction:: numpyro.contrib.hsgp.approximation.hsgp_squared_exponential

hsgp_approximation_matern
-------------------------
.. autofunction:: numpyro.contrib.hsgp.approximation.hsgp_approximation_matern
hsgp_matern
-----------
.. autofunction:: numpyro.contrib.hsgp.approximation.hsgp_matern

hsgp_approximation_periodic_non_centered
-----------------------------------------
.. autofunction:: numpyro.contrib.hsgp.approximation.hsgp_approximation_periodic_non_centered
hsgp_periodic_non_centered
--------------------------
.. autofunction:: numpyro.contrib.hsgp.approximation.hsgp_periodic_non_centered
4 changes: 2 additions & 2 deletions notebooks/source/hsgp_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"import jax.numpy as jnp\n",
"\n",
"import numpyro\n",
"from numpyro.contrib.hsgp.approximation import hsgp_approximation_squared_exponential\n",
"from numpyro.contrib.hsgp.approximation import hsgp_squared_exponential\n",
"from numpyro.contrib.hsgp.laplacian import eigenfunctions\n",
"from numpyro.contrib.hsgp.spectral_densities import (\n",
" diag_spectral_density_squared_exponential,\n",
Expand Down Expand Up @@ -187,7 +187,7 @@
" length = numpyro.sample(\"length\", dist.InverseGamma(concentration=6, rate=1))\n",
" noise = numpyro.sample(\"noise\", dist.InverseGamma(concentration=12, rate=10))\n",
" # --- Parametrization ---\n",
" f = hsgp_approximation_squared_exponential(\n",
" f = hsgp_squared_exponential(\n",
" x=x, alpha=alpha, length=length, ell=ell, m=m, non_centered=non_centered\n",
" )\n",
" # --- Likelihood ---\n",
Expand Down
6 changes: 3 additions & 3 deletions numpyro/contrib/hsgp/approximation.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def linear_approximation(
return _centered_approximation(phi, spd, m)


def hsgp_approximation_squared_exponential(
def hsgp_squared_exponential(
x: ArrayImpl,
alpha: float,
length: float,
Expand Down Expand Up @@ -99,7 +99,7 @@ def hsgp_approximation_squared_exponential(
return linear_approximation(phi=phi, spd=spd, m=m, non_centered=non_centered)


def hsgp_approximation_matern(
def hsgp_matern(
x: ArrayImpl,
nu: float,
alpha: float,
Expand Down Expand Up @@ -140,7 +140,7 @@ def hsgp_approximation_matern(
return linear_approximation(phi=phi, spd=spd, m=m, non_centered=non_centered)


def hsgp_approximation_periodic_non_centered(
def hsgp_periodic_non_centered(
x: ArrayImpl, alpha: float, length: float, w0: float, m: int
) -> ArrayImpl:
"""
Expand Down
18 changes: 8 additions & 10 deletions test/contrib/hsgp/test_approximation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import numpyro
from numpyro.contrib.hsgp.approximation import (
hsgp_approximation_matern,
hsgp_approximation_periodic_non_centered,
hsgp_approximation_squared_exponential,
hsgp_matern,
hsgp_periodic_non_centered,
hsgp_squared_exponential,
)
import numpyro.distributions as dist
from numpyro.handlers import scope, seed, trace
Expand Down Expand Up @@ -48,9 +48,7 @@ def test_approximation_squared_exponential(x, alpha, length, ell, m, non_centere
def model(x, alpha, length, ell, m, non_centered):
numpyro.deterministic(
"f",
hsgp_approximation_squared_exponential(
x, alpha, length, ell, m, non_centered
),
hsgp_squared_exponential(x, alpha, length, ell, m, non_centered),
)

rng_key = random.PRNGKey(0)
Expand All @@ -74,7 +72,7 @@ def model(x, alpha, length, ell, m, non_centered):
def test_approximation_matern(x, nu, alpha, length, ell, m, non_centered):
def model(x, nu, alpha, length, ell, m, non_centered):
numpyro.deterministic(
"f", hsgp_approximation_matern(x, nu, alpha, length, ell, m, non_centered)
"f", hsgp_matern(x, nu, alpha, length, ell, m, non_centered)
)

rng_key = random.PRNGKey(0)
Expand Down Expand Up @@ -102,7 +100,7 @@ def test_squared_exponential_gp_one_dim_model(
def latent_gp(x, alpha, length, ell, m, non_centered):
return numpyro.deterministic(
"f",
hsgp_approximation_squared_exponential(
hsgp_squared_exponential(
x=x, alpha=alpha, length=length, ell=ell, m=m, non_centered=non_centered
),
)
Expand Down Expand Up @@ -141,7 +139,7 @@ def test_matern_gp_one_dim_model(synthetic_one_dim_data, nu, ell, m, non_centere
def latent_gp(x, nu, alpha, length, ell, m, non_centered):
return numpyro.deterministic(
"f",
hsgp_approximation_matern(
hsgp_matern(
x=x,
nu=nu,
alpha=alpha,
Expand Down Expand Up @@ -191,7 +189,7 @@ def test_periodic_gp_one_dim_model(synthetic_one_dim_data, w0, m):
def latent_gp(x, alpha, length, w0, m):
return numpyro.deterministic(
"f",
hsgp_approximation_periodic_non_centered(
hsgp_periodic_non_centered(
x=x,
alpha=alpha,
length=length,
Expand Down

0 comments on commit 2b1e37d

Please sign in to comment.