
Rust-based t-SNE (GPU)
tsne_gpu.RdPerforms t-SNE dimensionality reduction on the input data.
The kNN search runs on the GPU. With the default "fft_3k_gpu" the
optimiser runs on the GPU as well, so the whole embedding stays on the
device; the other approximations optimise on the CPU.
Usage
tsne_gpu(
data,
knn = NULL,
n_dim = 2L,
perplexity = 20,
approx_type = c("fft_3k_gpu", "bh", "bh_qd", "fft", "fft_3k"),
knn_method = c("ivf", "exhaustive", "nndescent"),
nn_params = params_nn_gpu(),
tsne_params = params_tsne_gpu(),
seed = 42L,
backend = c("wgpu", "mlx"),
.verbose = TRUE
)Arguments
- data
Numerical matrix or data frame. The data to embed of shape samples x features. Will be coerced to a matrix.
- knn
Optional
NearestNeighboursclass. If provided, t-SNE will skip the k-nearest neighbour graph generation and use this one. Defaults toNULL. SeemanifoldsR::new_nearest_neighbour()for details.- n_dim
Integer. Number of dimensions in the embedding space. Currently only
2Lis supported. Defaults to2L.- perplexity
Numeric. Perplexity parameter, related to the number of nearest neighbours used in manifold learning. Typical values are between 5 and 50. Defaults to
20.0.- approx_type
Character. Approximation method for computing repulsive forces. One of
"fft_3k_gpu"(three-kernel FFT interpolation on the GPU, the default),"bh"for Barnes-Hut,"bh_qd"for the quick-and-dirty Barnes-Hut of qdtsne (tree depth capped atmax_depthinparams_tsne_gpu(), faster and coarser),"fft"for FFT-accelerated interpolation or"fft_3k"for its three-kernel variant (one forward and three inverse FFTs per epoch instead of four each). The last four run on the CPU.- knn_method
Character. GPU-accelerated (approximate) nearest neighbour method to use. One of
"nndescent","exhaustive", or"ivf".- nn_params
Named list. Nearest neighbour search parameters, see
params_nn_gpu(). tSNE usually needs a higher k, hence"ivf"is the default here.- tsne_params
Named list. t-SNE (GPU) algorithm parameters, see
params_tsne_gpu().- seed
Integer. Random seed for reproducibility. Defaults to
42L.- backend
String. One of
c("wgpu", "mlx")."mlx"runs the kNN search and the"fft_3k_gpu"optimiser on MLX (Apple Silicon, needs a build with the MLX backend, seemlx_available()). CPU optimisers stay on the CPU.- .verbose
Logical. Controls verbosity. Defaults to
TRUE.