wsingular
- wsingular.sinkhorn_singular_vectors(dataset: torch.Tensor, dtype: str, device: str, n_iter: int, tau: float = 0, eps: float = 0.05, p: int = 1, writer=None, small_value: float = 1e-06, normalization_steps: int = 1, C_ref: Optional[torch.Tensor] = None, D_ref: Optional[torch.Tensor] = None, log_loss: bool = False, progress_bar: bool = False) Tuple[torch.Tensor, torch.Tensor]
Performs power iterations and returns Sinkhorn Singular Vectors. Early stopping is possible with Ctrl-C.
- Parameters:
dataset (torch.Tensor) – The input dataset. Alternatively, you can give a tuple of tensors (A, B).
dtype (str) – The dtype
device (str) – The device
n_iter (int) – The number of power iterations.
tau (float, optional) – The regularization parameter for the norm R. Defaults to 0.
eps (float) – The entropic regularization parameter.
p (int, optional) – The order of the norm R. Defaults to 1.
writer (SummaryWriter, optional) – If set, the progress will be written to the Tensorboard writer. Defaults to None.
small_value (float, optional) – A small value for numerical stability. Defaults to 1e-6.
normalization_steps (int, optional) – How many Sinkhorn iterations for the initial normalization of the dataset. Must be > 0. Defaults to 1, which is just regular normalization, along columns for A and along rows for B. For large numbers of steps, A and B are bistochastic.
C_ref (torch.Tensor, optional) – If set, Hilbert distances to this reference will be computed. Defaults to None.
D_ref (torch.Tensor, optional) – If set, Hilbert distances to this reference will be computed. Defaults to None.
log_loss (bool, optional) – Whether to return the loss. Defaults to False.
progress_bar (bool, optional) – Whether to display a progress bar for individual matrix computations. Defaults to False.
- Returns:
Sinkhorn Singular Vectors (C,D). If log_loss, it returns (C, D, loss_C, loss_D)
- Return type:
Tuple[torch.Tensor, torch.Tensor]
- wsingular.stochastic_sinkhorn_singular_vectors(dataset: torch.Tensor, dtype: torch.dtype, device: str, n_iter: int, tau: float = 0, eps: float = 0.05, sample_prop: float = 0.1, p: int = 1, step_fn: ~typing.Callable = <function <lambda>>, mult_update: bool = False, writer=None, small_value: float = 1e-06, normalization_steps: int = 1, C_ref: ~typing.Optional[torch.Tensor] = None, D_ref: ~typing.Optional[torch.Tensor] = None, progress_bar: bool = False) Tuple[torch.Tensor, torch.Tensor]
Performs stochastic power iterations and returns Sinkhorn Singular Vectors. Early stopping is possible with Ctrl-C.
- Parameters:
dataset (torch.Tensor) – The input dataset. Alternatively, you can give a tuple of tensors (A, B).
dtype (torch.dtype) – The dtype
device (str) – The device
n_iter (int) – The number of power iterations.
tau (float, optional) – The regularization parameter for the norm R. Defaults to 0.
eps (float, optional) – The entropic regularization parameter. Defaults to 5e-2.
sample_prop (float, optional) – The proportion of indices to update at each step. Defaults to 1e-1.
p (int, optional) – The order of the norm R. Defaults to 1.
step_fn (Callable, optional) – The function that defines step size from the iteration number (which starts at 1). Defaults to lambdak:1/np.sqrt(k).
mult_update (bool, optional) – If True, use multiplicative update instead of additive update. Defaults to False.
writer (SummaryWriter, optional) – If set, the progress will be written to the Tensorboard writer. Defaults to None.
small_value (float, optional) – A small value for numerical stability. Defaults to 1e-6.
normalization_steps (int, optional) – How many Sinkhorn iterations for the initial normalization of the dataset. Must be > 0. Defaults to 1, which is just regular normalization, along columns for A and along rows for B. For large numbers of steps, A and B are bistochastic.
C_ref (torch.tensor, optional) – If set, Hilbert distances to this reference will be computed. Defaults to None.
D_ref (torch.Tensor, optional) – If set, Hilbert distances to this reference will be computed. Defaults to None.
progress_bar (bool, optional) – Whether to display a progress bar for individual matrix computations. Defaults to False.
- Returns:
Sinkhorn Singular Vectors (C,D)
- Return type:
Tuple[torch.Tensor, torch.Tensor]
- wsingular.stochastic_wasserstein_singular_vectors(dataset: torch.Tensor, dtype: torch.dtype, device: str, n_iter: int, tau: float = 0, sample_prop: float = 0.1, p: int = 1, step_fn: ~typing.Callable = <function <lambda>>, mult_update: bool = False, writer=None, small_value: float = 1e-06, normalization_steps: int = 1, C_ref: ~typing.Optional[torch.Tensor] = None, D_ref: ~typing.Optional[torch.Tensor] = None, progress_bar: bool = False) Tuple[torch.Tensor, torch.Tensor]
Performs stochastic power iterations and returns Wasserstein Singular Vectors. Early stopping is possible with Ctrl-C.
- Parameters:
dataset (torch.Tensor) – The input dataset. Alternatively, you can give a tuple of tensors (A, B).
dtype (torch.dtype) – The dtype
device (str) – The device
n_iter (int) – The number of power iterations.
tau (float, optional) – The regularization parameter for the norm R. Defaults to 0.
sample_prop (float, optional) – The proportion of indices to update at each step. Defaults to 1e-1.
p (int, optional) – The order of the norm R. Defaults to 1.
step_fn (Callable, optional) – The function that defines step size from the iteration number (which starts at 1). Defaults to lambdak:1/np.sqrt(k).
mult_update (bool, optional) – If True, use multiplicative update instead of additive update. Defaults to False.
writer (SummaryWriter, optional) – If set, the progress will be written to the Tensorboard writer. Defaults to None.
small_value (float, optional) – A small value for numerical stability. Defaults to 1e-6.
normalization_steps (int, optional) – How many Sinkhorn iterations for the initial normalization of the dataset. Must be > 0. Defaults to 1, which is just regular normalization, along columns for A and along rows for B. For large numbers of steps, A and B are bistochastic.
C_ref (torch.tensor, optional) – If set, Hilbert distances to this reference will be computed. Defaults to None.
D_ref (torch.Tensor, optional) – If set, Hilbert distances to this reference will be computed. Defaults to None.
progress_bar (bool, optional) – Whether to display a progress bar for individual matrix computations. Defaults to False.
- Returns:
Wasserstein Singular Vectors (C,D)
- Return type:
Tuple[torch.Tensor, torch.Tensor]
- wsingular.wasserstein_singular_vectors(dataset: torch.Tensor, dtype: torch.dtype, device: str, n_iter: int, tau: float = 0, p: int = 1, writer=None, small_value: float = 1e-06, normalization_steps: int = 1, C_ref: Optional[torch.Tensor] = None, D_ref: Optional[torch.Tensor] = None, log_loss: bool = False, progress_bar: bool = False) Tuple[torch.Tensor, torch.Tensor]
Performs power iterations and returns Wasserstein Singular Vectors. Early stopping is possible with Ctrl-C.
- Parameters:
dataset (torch.Tensor) – The input dataset, rows as samples. Alternatively, you can give a tuple of tensors (A, B).
dtype (str) – The dtype
device (str) – The device
n_iter (int) – The number of power iterations.
tau (float, optional) – The regularization parameter for the norm R. Defaults to 0.
p (int, optional) – The order of the norm R. Defaults to 1.
writer (SummaryWriter, optional) – If set, the progress will be written to the Tensorboard writer. Defaults to None.
small_value (float, optional) – A small value for numerical stability. Defaults to 1e-6.
normalization_steps (int, optional) – How many Sinkhorn iterations for the initial normalization of the dataset. Must be > 0. Defaults to 1, which is just regular normalization, along columns for A and along rows for B. For large numbers of steps, A and B are bistochastic.
C_ref (torch.Tensor, optional) – If set, Hilbert distances to this reference will be computed. Defaults to None.
D_ref (torch.Tensor, optional) – If set, Hilbert distances to this reference will be computed. Defaults to None.
log_loss (bool, optional) – Whether to return the loss. Defaults to False.
progress_bar (bool, optional) – Whether to display a progress bar for individual matrix computations. Defaults to False.
- Returns:
Wasserstein sigular vectors (C,D). If log_loss, it returns (C, D, loss_C, loss_D)
- Return type:
Tuple[torch.Tensor, torch.Tensor]