Clustering after pruning

Hi,

I tried to use clustering after pruning the model using the example pruning code by tensorflow.

I getting this error:
/usr/local/lib/python3.7/dist-packages/tensorflow_model_optimization/python/core/clustering/keras/cluster_wrapper.py in build(self, input_shape)
165 # stripping
166 position_original_weight = next(
→ 167 i for i, w in enumerate(self.layer.weights) if w is original_weight)
168 self.position_original_weights[position_original_weight] = weight_name
169
StopIteration

Can someone please help me understand the issue and if it is possible to do clustering after pruning.

Sparsity preserving clustering Keras example  |  TensorFlow Model Optimization might help you

I guess you didn’t strip pruning wrapper layer. You can apply clustering to the vanilla model without pruning wrapper. See end of the section - Sparsity preserving clustering Keras example  |  TensorFlow Model Optimization

Anyway, you can follow the instructions in there to run sparsity + clustering , as David suggested.