tensorflow / tensorflow/model-optimization

Not able to cluster Conv1DTranspose layer

Open
#940 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
1.6k
Forks
349
Avg merge
3d 2h
Merged PRs (30d)
1

Description

Hi,
Describe the bug
A clear and concise description of what the bug is.

Getting below error while trying to cluster the convolution layers. Is Conv1DTranspose clustering is possible or not? Can anyone suggest how to solve this.

Please initialize Clusterwith a supported layer. Layers should either be aClusterableLayer instance, or should be supported by the ClusteringRegistry. You passed: <class 'keras.layers.convolutional.Conv1DTranspose'>

System information

TensorFlow version (installed from source or binary): Binary

TensorFlow Model Optimization version (installed from source or binary): 0.7.1

Python version: 3.8

Describe the expected behavior

Describe the current behavior

Code to reproduce the issue
Provide a reproducible code that is the bare minimum necessary to generate the
problem.

import tensorflow as tf
import tensorflow_model_optimization as tfmot

cluster_weights = tfmot.clustering.keras.cluster_weights
CentroidInitialization = tfmot.clustering.keras.CentroidInitialization

time_dat = tf.keras.layers.Input(batch_shape=(1, 16000))
x1 = tf.keras.layers.Conv1D(10, 256, 64, padding = "valid",use_bias=False)(tf.expand_dims(time_dat, axis=-1))
x2 = tf.keras.layers.Conv1DTranspose(1, 256, 64, padding = "valid",use_bias=False)(x1)
model = tf.keras.models.Model(inputs=time_dat, outputs=[x2])

clustering_params = {
  'number_of_clusters': 50,
  'cluster_centroids_init': CentroidInitialization.LINEAR
}

def apply_clustering_to_dense(layer):
  if isinstance(layer, tf.keras.layers.Conv1D):
    return cluster_weights(layer, **clustering_params)
  return layer

clustered_model = tf.keras.models.clone_model(
    model,
    clone_function=apply_clustering_to_dense,
)

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided TensorFlow Model Optimization reproduction with Conv1DTranspose and review the ClusterableLayer and ClusteringRegistry support named in the error. Determine whether Conv1DTranspose is intended to be supported; done means the support status and expected clustering behavior are clear and the reproduction no longer produces the reported unsupported-layer error.

Written by the indexing model from the issue text.

Assessment

Tech stack
keras, python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.