Neuralized K-Means: make k-means amenable to neural network explanations #198
Labels
enhancement
New feature or request
model compatibility
Compatibility for new or variations of existing models
Description
K-Means finds some centroids$\mathbf{\mu}_1,\ldots,\mathbf{\mu}_K$ and assigns data points to a cluster as $c = {\rm argmin}_k \lbrace \Vert\boldsymbol{x} - \mathbf{\mu}_k\Vert^2\rbrace$ , or in code:
Neither the assignment$c$ nor the distance $\Vert\boldsymbol{x} - \mathbf{\mu}_c\Vert^2$ are really explainable.$c$ is not continuous, and the distance is in fact measuring a dissimilarity to the cluster, essentially the opposite of what we want to explain.
The assignment
Fixes
From Clustering to Cluster Explanation via Neural Networks (2022) present a method based on neuralization. They show that the k-means cluster assignment can be exactly rewritten as a set of piecewise linear functions
and the original k-means cluster assignment can be recovered as$c = {\rm argmax}_k\lbrace f_k(\boldsymbol{x})\rbrace$ .
The cluster discriminant$f_c$ is a measure of cluster membership (instead of a dissimilarity) and is also structurally amenable to LRP and friends. It can also be plugged on top of a neural network feature extractor to make deep cluster assignments explainable.
Additional Information
torch.nn.Module
modules, such module would need to be addedor alternatively via
torch.einsum
, which I think is easier. Either way, a special layer is needed for that.LogMeanExpPool
layer. Alternative could be to implement aMinPool
layer with a custom LRP rule.The text was updated successfully, but these errors were encountered: