OCDocker.OCScore.Dimensionality.future.utils module

Utilities for the future Autoencoder pipeline.

OCDocker.OCScore.Dimensionality.future.utils.apply_noise(inputs, noise_type='none', mask_prob=0.0, gaussian_std=0.0, swap_prob=0.0)[source]

Apply input noise for denoising autoencoder training.

Parameters:
  • inputs (torch.Tensor) – Input batch tensor.

  • noise_type (str, optional) – Noise strategy string (e.g., “mask”, “gaussian”, “swap”, combos), by default “none”.

  • mask_prob (float, optional) – Feature masking probability, by default 0.0.

  • gaussian_std (float, optional) – Gaussian noise standard deviation, by default 0.0.

  • swap_prob (float, optional) – Swap noise probability, by default 0.0.

Returns:

Noised input tensor.

Return type:

torch.Tensor

OCDocker.OCScore.Dimensionality.future.utils.embedding_stats(embeddings, collapse_threshold=1e-06)[source]

Compute basic embedding statistics.

Parameters:
  • embeddings (np.ndarray) – Embedding matrix (N, D).

  • collapse_threshold (float, optional) – Variance threshold to define collapsed dimensions, by default 1e-6.

Returns:

Dictionary with variance, collapse rate, and mean norm.

Return type:

Dict[str, object]

OCDocker.OCScore.Dimensionality.future.utils.ramp_weight(target, epoch, ramp_epochs, ramp_type='linear')[source]

Compute ramped weight value for a given epoch.

Parameters:
  • target (float) – Final target weight.

  • epoch (int) – Current epoch index (0-based).

  • ramp_epochs (int) – Number of epochs to ramp over.

  • ramp_type (str, optional) – Ramp schedule type (“linear” or “sigmoid”), by default “linear”.

Returns:

Ramped weight for the given epoch.

Return type:

float

OCDocker.OCScore.Dimensionality.future.utils.spearman_corr(x, y)[source]

Compute Spearman correlation (rank-based Pearson).

Parameters:
  • x (np.ndarray) – First input vector.

  • y (np.ndarray) – Second input vector.

Returns:

Spearman correlation coefficient.

Return type:

float