I have a tensor x of shape [32, 10, 128]
, where:
-
32
is the batch size, -
10
represents nodes, -
128
denotes features per
node.
My objective is to compute node similarities based on their features across each batch input independently. Specifically, I aim to cluster nodes within each input using KMeans clustering on their feature similarities. The end goal is to aggregate nodes that are similar in feature space into clusters and then compute a representative average feature vector for each cluster.
Key requirements:
- Perform KMeans clustering independently for each input.
- Utilize Torch to leverage GPU acceleration effectively to execute all the batch inputs parallelly.
Could someone guide me on how to implement this efficiently in Torch?