Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ class LinearCentroidsInitialisation(AbstractCentroidsInitialisation):
def _calculate_centroids_for_interval(self, weight_interval,
number_of_clusters_for_interval):
if tf.math.less_equal(number_of_clusters_for_interval, 0):
# Return an empty array of centroids
return tf.constant([])

weight_min = tf.reduce_min(weight_interval)
Expand Down Expand Up @@ -247,6 +246,10 @@ class RandomCentroidsInitialisation(AbstractCentroidsInitialisation):

def _calculate_centroids_for_interval(self, weight_interval,
number_of_clusters_for_interval):
if tf.math.less_equal(number_of_clusters_for_interval, 0):
# Return an empty array of centroids
return tf.constant([])

weight_min = tf.reduce_min(weight_interval)
weight_max = tf.reduce_max(weight_interval)
cluster_centroids = tf.random.uniform(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def testDensityBasedClusterCentroidsWithSparsityPreservation(
@parameterized.parameters(
([0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.], 5),
([0., 1., 2., 3., 3.1, 3.2, 3.3, 3.4, 3.5], 3),
([1.0, 2.0, 3.0], 3),
([-3., -2., -1., 0., 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.], 6))
def testRandomClusterCentroidsWithSparsityPreservation(
self, weights, number_of_clusters):
Expand Down
Loading