File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed
tensorflow_model_optimization/python/core/clustering/keras Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -108,17 +108,8 @@ def cluster_weights(to_cluster,
108
108
number_of_clusters: the number of cluster centroids to form when
109
109
clustering a layer/model. For example, if number_of_clusters=8 then only
110
110
8 unique values will be used in each weight array.
111
- cluster_centroids_init: enum value that determines how the cluster
112
- centroids will be initialized.
113
- Can have following values:
114
- 1. RANDOM : centroids are sampled using the uniform distribution
115
- between the minimum and maximum weight values in a given layer
116
- 2. DENSITY_BASED : density-based sampling. First, cumulative
117
- distribution function is built for weights, then y-axis is evenly
118
- spaced into number_of_clusters regions. After this the corresponding x
119
- values are obtained and used to initialize clusters centroids.
120
- 3. LINEAR : cluster centroids are evenly spaced between the minimum
121
- and maximum values of a given weight
111
+ cluster_centroids_init: `cluster_config.CentroidInitialization` instance
112
+ that determines how the cluster centroids will be initialized.
122
113
**kwargs: Additional keyword arguments to be passed to the keras layer.
123
114
Ignored when to_cluster is not a keras layer.
124
115
Original file line number Diff line number Diff line change 18
18
19
19
20
20
class CentroidInitialization (str , enum .Enum ):
21
+ """Specifies how the cluster centroids should be initialized.
22
+ * `LINEAR`: Cluster centroids are evenly spaced between the minimum and
23
+ maximum values of a given weight tensor.
24
+ * `RANDOM`: Centroids are sampled using the uniform distribution between the
25
+ minimum and maximum weight values in a given layer.
26
+ * `DENSITY_BASED`: Density-based sampling obtained as follows: first a
27
+ cumulative distribution function is built for the weights, then the Y
28
+ axis is evenly spaced into as many regions as many clusters we want to
29
+ have. After this the corresponding X values are obtained and used to
30
+ initialize the clusters centroids.
31
+ """
21
32
LINEAR = "LINEAR"
22
33
RANDOM = "RANDOM"
23
34
DENSITY_BASED = "DENSITY_BASED"
You can’t perform that action at this time.
0 commit comments