{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# K-means clustering - PyTorch API\n\nThe :meth:`pykeops.torch.LazyTensor.argmin` reduction supported by KeOps :class:`pykeops.torch.LazyTensor` allows us\nto perform **bruteforce nearest neighbor search** with four lines of code.\nIt can thus be used to implement a **large-scale** \n[K-means clustering](https://en.wikipedia.org/wiki/K-means_clustering),\n**without memory overflows**.\n\n
For large and high dimensional datasets, this script \n **outperforms its NumPy counterpart**\n as it avoids transfers between CPU (host) and GPU (device) memories.