starling.structure.coordinates.distance_matrix_to_3d_structure_torch_mds
- distance_matrix_to_3d_structure_torch_mds(target_distances, batch_size=100, n_iter=300, tol=0.0001, device='cuda', progress_bar=True)[source]
SMACOF implementation using PyTorch with support for batched processing.
NB; as of Feb 2024 this is substantially slower for MPS than the other approach, because MPS seems to fail and fall back on CPU in this parallelized version. This is 1.5-2x slower than the other approach. To keep this simple, there is a check in the parent function generate_3d_coordinates_from_distances() that defaults to the non-torch implementation if the device is MPS and we’re on macOS <= 14. Hopefully this is fixed in macOS15…
Parameters:
- target_distances: pytorch.Tensor
tensor of shape (total_samples, n_points, n_points)
- batch_size: int
size of each processing batch.
- n_iter: int
Maximum number of iterations.
- tol: float
Convergence tolerance.
- device: str
Device to use for computation.
- progress_bar: bool
Whether to display a progress bar.
Returns:
tuple
[0] pytorch.Tensor; A tensor of shape (total_samples, n_points, 3) [1] pytorch.Tensor; A tensor of shape (total_samples, n_iter)