{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Linking KeOps with scipy.sparse.linalg\n\nThe [scipy library](https://docs.scipy.org/doc/scipy/reference/sparse.linalg.html)\nprovides a simple abstraction for implicit tensors:\nthe [LinearOperator](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.LinearOperator.html)\nclass,\nwhich represents generic \"Matrix-Vector\" products\nand can be plugged seamlessly in a [large collection](https://docs.scipy.org/doc/scipy/reference/sparse.linalg.html) \nof linear algebra routines.\n\nCrucially, KeOps :class:`pykeops.torch.LazyTensor` are now **fully compatible**\nwith this interface.\nAs an example, let's see how to combine KeOps with a \n[fast eigenproblem solver](https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.eigsh.html) \nto compute **spectral coordinates** on a large 2D or 3D point cloud.\n\n
Ideally, we'd like to interface KeOps with some\n methods of the [scikit-learn library](https://scikit-learn.org/stable/)...\n But this seems out of reach, as most of the sklearn codebase\n relies internally on **explicit numpy arrays**. One day, maybe!
In higher-dimensional settings, the simplistic\n :func:`grid_cluster
On very large problems, a custom eigenproblem solver\n implemented with the **PyTorch+KeOps** interface should be sensibly **faster**\n than this SciPy wrapper: performing all computations on the GPU\n would allow us to perform linear operations in parallel\n and to **skip hundreds of unnecessary Host-Device memory transfers**.