tensorflow / model-optimization

A toolkit to optimize ML models for deployment for Keras and TensorFlow, including quantization and pruning.
https://www.tensorflow.org/model_optimization
Apache License 2.0
1.49k stars 319 forks source link

[clustering] Possible wrong call of the centroids initializer from the ClusterWeights wrapper #939

Open aserenko opened 2 years ago

aserenko commented 2 years ago

An instance of the centroids initializer expects to be initialized with data_format. However, instead of data_format it gets num_channels here: https://github.com/tensorflow/model-optimization/blob/v0.7.1/tensorflow_model_optimization/python/core/clustering/keras/cluster_wrapper.py#L218 I suppose that line is erroneous. This may cause looping over the the wrong axis during clusterization when data_format is channels_first.

wwwind commented 2 years ago

Hi @aserenko Thank you for the reported bug. The fix is in this PR https://github.com/tensorflow/model-optimization/pull/951