tensorflow / tensorflow/model-optimization
ValueError: `to_annotate` can only be a `keras.layers.Layer` instance. You passed an instance of type: Dense.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.6k
- Forks
- 349
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 1
Description
import tensorflow as tf
from tensorflow.keras import layers, models
import tensorflow_model_optimization as tfmot
input_shape = (20,)
annotated_model = tf.keras.Sequential([
tfmot.quantization.keras.quantize_annotate_layer(tf.keras.layers.Dense(20, input_shape=input_shape)),
tf.keras.layers.Flatten()
])
quant_aware_model = tfmot.quantization.keras.quantize_apply(annotated_model)
quant_aware_model.summary()
when I run the above code, it appears error like: "ValueError: to_annotate can only be a keras.layers.Layer instance. You passed an instance of type: Dense."
Does anyone know the way to handle it? Thanks a lot.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the minimal TensorFlow Model Optimization example from the issue and compare the installed TensorFlow and Keras versions with the API's expected layer type. Trace quantize_annotate_layer and quantize_apply to identify the compatibility boundary; done means the reproduction has a confirmed cause and a documented supported configuration or workaround.
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
- Mostly clear
- Newbie friendliness
- 35/100