DepthwiseConv2D Layers cannot be clustered or sparsely pruned
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python, tensorflow
- Ambito
- machine-learning
Direzione di ricerca
Inizia eseguendo la riproduzione MNIST fornita con le API cluster_weights e sparse pruning di TensorFlow Model Optimization. Traccia il modo in cui vengono gestiti i kernel di DepthwiseConv2D, quindi verifica che il clustering produca tre pesi unici e che il pruning m-by-n produca il pattern di sparsity previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
When attempting to sparsely prune or cluster DepthwiseConv2D Layers it appears that no clustering or sparse pruning actually occurs.
System information
TensorFlow version (installed from source or binary): 2.16.1/2.15.1
TensorFlow Model Optimization version (installed from source or binary): 0.8.0/0.7.5
Python version: 3.9.18
Describe the expected behavior
I should see that the kernel for the Depthwise layer should have 3 unique weights, not 9.
Describe the current behavior
The Depthwise layer has 9 unique weights
The same issue occurs for sparse m by n pruning, the weights are not pruned correctly in an m by n manner
Code to reproduce the issue
import tensorflow as tf
import tensorflow_model_optimization as tfmot
from tensorflow import keras
import numpy as np
(train_images, train_labels), (test_images, test_labels) = tf.keras.datasets.mnist.load_data()
train_images = train_images / 255.0
test_images = test_images / 255.0
model = keras.Sequential([
keras.layers.InputLayer(input_shape=(28, 28)),
keras.layers.Reshape(target_shape=(28, 28, 1)),
keras.layers.DepthwiseConv2D(kernel_size=(3, 3), activation=tf.nn.relu),
keras.layers.MaxPooling2D(pool_size=(2, 2)),
keras.layers.Flatten(),
keras.layers.Dense(10)
])
model.compile(optimizer='adam',
loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=['accuracy'])
model.fit(
train_images,
train_labels,
validation_split=0.1,
epochs=10
)
cluster_weights = tfmot.clustering.keras.cluster_weights
CentroidInitialization = tfmot.clustering.keras.CentroidInitialization
clustering_params = {
'number_of_clusters': 3,
'cluster_centroids_init': CentroidInitialization.LINEAR
}
clustered_model = cluster_weights(model, **clustering_params)
opt = keras.optimizers.Adam(learning_rate=1e-5)
clustered_model.compile(
loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
optimizer=opt,
metrics=['accuracy'])
clustered_model.fit(
train_images,
train_labels,
batch_size=500,
epochs=1,
validation_split=0.1)
for layer in model.layers:
for weight in layer.weights:
print(weight.name)
print(len(np.unique(weight)))
- Lingua principale
- Python
- Stelle
- 1.6k
- Fork
- 349
- Merge medio
- 3g 2h
- PR unite (30g)
- 1
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di tensorflow/model-optimization
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
tensorflow/model-optimization#1301 · 1 commento ·
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
tensorflow/model-optimization#1272 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 50/100
tensorflow/model-optimization#1270 · 2 commenti ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
tensorflow/model-optimization#1241 ·
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
tensorflow/model-optimization#1182 · 1 commento ·
Tutte le issue di tensorflow/model-optimization
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
-
hcocena Apertapolicies-accepted pre-review precheck-passed
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
Bioconductor/BiocContributions#214 · 5 commenti ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
TencentCloud/Octop#1169 · 1 commento ·
-
[开源推荐] 在老板拷问你之前,先让 AI 灵魂拷问你 Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
521xueweihan/HelloGitHub#3778 ·
-
The version checker's trailing attribute region has no control for a less-than inside a quoted value Apertaarea: dashboard area: tests bug perceived difficulty: 2 python
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Nitjsefnie-Harness-Commons/daedalus#1105 · 1 commento ·