Skip to content

Commit

Permalink
remove: items slated for removal in v0.4.0
Browse files Browse the repository at this point in the history
Refs: #785
  • Loading branch information
rg936672 committed Feb 7, 2025
1 parent 94a1a2d commit 763bc25
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 303 deletions.
271 changes: 0 additions & 271 deletions coreax/kernel.py

This file was deleted.

33 changes: 1 addition & 32 deletions coreax/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class factories and checks for numerical precision.
import jax.tree_util as jtu
from jax import Array, block_until_ready, jit, vmap
from jaxtyping import Shaped
from typing_extensions import TypeAlias, deprecated
from typing_extensions import TypeAlias

_logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO, stream=sys.stdout)
Expand Down Expand Up @@ -236,37 +236,6 @@ def difference(
return x - y


@deprecated(
"Use coreax.kernels.util.median_heuristic instead."
+ " Deprecated since version 0.3.0."
+ " Will be removed in version 0.4.0."
)
@jit
def median_heuristic(
x: Union[Shaped[Array, " n d"], Shaped[Array, " n"], Shaped[Array, ""], float, int],
) -> Shaped[Array, ""]:
"""
Compute the median heuristic for setting kernel bandwidth.
Analysis of the performance of the median heuristic can be found in
:cite:`garreau2018median`.
:param x: Input array of vectors
:return: Bandwidth parameter, computed from the median heuristic, as a
zero-dimensional array
"""
# Format inputs
x = jnp.atleast_2d(x)
# Calculate square distances as an upper triangular matrix
square_distances = jnp.triu(pairwise(squared_distance)(x, x), k=1)
# Calculate the median of the square distances
median_square_distance = jnp.median(
square_distances[jnp.triu_indices_from(square_distances, k=1)]
)

return jnp.sqrt(median_square_distance / 2.0)


def sample_batch_indices(
random_key: KeyArrayLike,
max_index: int,
Expand Down

0 comments on commit 763bc25

Please sign in to comment.