Skip to content

Commit 0da299b

Browse files
alanchiaotensorflower-gardener
authored andcommitted
Add additional background for why strip_pruning and gzip are relevant in exporting compressed models.
PiperOrigin-RevId: 325046042
1 parent b5946e9 commit 0da299b

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

tensorflow_model_optimization/g3doc/guide/pruning/pruning_with_keras.ipynb

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
{
1414
"cell_type": "code",
15-
"execution_count": 0,
15+
"execution_count": null,
1616
"metadata": {
1717
"cellView": "form",
1818
"colab": {},
@@ -107,7 +107,7 @@
107107
},
108108
{
109109
"cell_type": "code",
110-
"execution_count": 0,
110+
"execution_count": null,
111111
"metadata": {
112112
"colab": {},
113113
"colab_type": "code",
@@ -120,7 +120,7 @@
120120
},
121121
{
122122
"cell_type": "code",
123-
"execution_count": 0,
123+
"execution_count": null,
124124
"metadata": {
125125
"colab": {},
126126
"colab_type": "code",
@@ -151,7 +151,7 @@
151151
},
152152
{
153153
"cell_type": "code",
154-
"execution_count": 0,
154+
"execution_count": null,
155155
"metadata": {
156156
"colab": {},
157157
"colab_type": "code",
@@ -202,7 +202,7 @@
202202
},
203203
{
204204
"cell_type": "code",
205-
"execution_count": 0,
205+
"execution_count": null,
206206
"metadata": {
207207
"colab": {},
208208
"colab_type": "code",
@@ -257,7 +257,7 @@
257257
},
258258
{
259259
"cell_type": "code",
260-
"execution_count": 0,
260+
"execution_count": null,
261261
"metadata": {
262262
"colab": {},
263263
"colab_type": "code",
@@ -319,7 +319,7 @@
319319
},
320320
{
321321
"cell_type": "code",
322-
"execution_count": 0,
322+
"execution_count": null,
323323
"metadata": {
324324
"colab": {},
325325
"colab_type": "code",
@@ -351,7 +351,7 @@
351351
},
352352
{
353353
"cell_type": "code",
354-
"execution_count": 0,
354+
"execution_count": null,
355355
"metadata": {
356356
"colab": {},
357357
"colab_type": "code",
@@ -378,7 +378,7 @@
378378
},
379379
{
380380
"cell_type": "code",
381-
"execution_count": 0,
381+
"execution_count": null,
382382
"metadata": {
383383
"colab": {},
384384
"colab_type": "code",
@@ -420,12 +420,16 @@
420420
"Both `tfmot.sparsity.keras.strip_pruning` and applying a standard compression algorithm (e.g. via gzip) are necessary to see the compression\n",
421421
"benefits of pruning.\n",
422422
"\n",
423+
"* `strip_pruning` is necessary since it removes every tf.Variable that pruning only needs during training, which would otherwise add to model size during inference\n",
424+
"* Applying a standard compression algorithm is necessary since the serialized weight matrices are the same size as they were before pruning. However, pruning makes most of the weights zeros, which is\n",
425+
"added redundancy that algorithms can utilize to further compress the model.\n",
426+
"\n",
423427
"First, create a compressible model for TensorFlow."
424428
]
425429
},
426430
{
427431
"cell_type": "code",
428-
"execution_count": 0,
432+
"execution_count": null,
429433
"metadata": {
430434
"colab": {},
431435
"colab_type": "code",
@@ -452,7 +456,7 @@
452456
},
453457
{
454458
"cell_type": "code",
455-
"execution_count": 0,
459+
"execution_count": null,
456460
"metadata": {
457461
"colab": {},
458462
"colab_type": "code",
@@ -483,7 +487,7 @@
483487
},
484488
{
485489
"cell_type": "code",
486-
"execution_count": 0,
490+
"execution_count": null,
487491
"metadata": {
488492
"colab": {},
489493
"colab_type": "code",
@@ -515,7 +519,7 @@
515519
},
516520
{
517521
"cell_type": "code",
518-
"execution_count": 0,
522+
"execution_count": null,
519523
"metadata": {
520524
"colab": {},
521525
"colab_type": "code",
@@ -550,7 +554,7 @@
550554
},
551555
{
552556
"cell_type": "code",
553-
"execution_count": 0,
557+
"execution_count": null,
554558
"metadata": {
555559
"colab": {},
556560
"colab_type": "code",
@@ -595,7 +599,7 @@
595599
},
596600
{
597601
"cell_type": "code",
598-
"execution_count": 0,
602+
"execution_count": null,
599603
"metadata": {
600604
"colab": {},
601605
"colab_type": "code",
@@ -647,7 +651,7 @@
647651
},
648652
{
649653
"cell_type": "code",
650-
"execution_count": 0,
654+
"execution_count": null,
651655
"metadata": {
652656
"colab": {},
653657
"colab_type": "code",

0 commit comments

Comments
 (0)