torchgeo_bench.intrinsic_dim#

Wrapper around the torchid intrinsic-dimension estimators. Used by torchgeo_bench.main.evaluate_intrinsic_dim() to attach method="intrinsic_dim" rows to the standard results CSV alongside the KNN and linear-probe metrics.

The torchid dependency is optional and gated behind the [id] extra in pyproject.toml (it requires Python ≥ 3.13). When the dependency is not installed an ImportError is raised on first use.

Public API#

torchgeo_bench.intrinsic_dim.compute_intrinsic_dim(X, estimators, device=None, max_samples=10000, seed=0)[source][source]#

Compute intrinsic dimension of X for each requested estimator.

Parameters:
  • X (ndarray) – Feature matrix of shape (n_samples, n_features).

  • estimators (list[str]) – Names of torchid global estimators (see SUPPORTED_ESTIMATORS).

  • device (str | device | None) – "cuda", "cpu", a torch.device, or None to auto-select (CUDA when available, otherwise CPU).

  • max_samples (int | None) – Cap row count via random subsampling for speed/memory. None disables subsampling.

  • seed (int) – RNG seed for subsampling determinism.

Returns:

Mapping {estimator_name: dimension}. Estimator-internal exceptions propagate; we no longer swallow them as NaN, because doing so previously hid the TwoNN/fp32-zero-distance bug.

Return type:

dict[str, float]