def closest_centroids(self, points, centroids): centroids = R.expand_dims(centroids, axis=1) return R.argmin( R.square_root(R.sum(R.square(R.sub(points, centroids)), axis=2)))
def closest_centroids(self, centroids): centroids = R.expand_dims(centroids, axis=1) return R.argmin( square_root( R.sub(self.points, centroids).pow(Scalar(2)).sum(axis=2)))