Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit 2cd19ee

Browse files
committed
Update tfmot compression api RFC: add indent.
1 parent 69aa00d commit 2cd19ee

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

rfcs/20201221-tfmot-compression-api.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,46 +375,56 @@ Now we'll explain when each method is called and how many that method called for
375375
<p align="center">
376376
<img src=20201221-tfmot-compression-api/get_compressible_weights.png />
377377
</p>
378+
378379
```python
379380
training_model = optimize_training(model, params)
380381
```
382+
381383
`get_compressible_weights` is called when we want to get a list of variables that we will apply compression.
382384
When we try to compress the pre-trained model, we just call this method for each layer in the pre-trained model. The number of the method calling is (# of layers).
383385
384386
1. `init_training_weights_repr`
385387
<p align="center">
386388
<img src=20201221-tfmot-compression-api/init_training_weights_repr.png />
387389
</p>
390+
388391
```python
389392
training_model = optimize_training(model, params)
390393
```
394+
391395
`init_training_weights_repr` is called when we initialize the cloned training model from the pre-trained model. `optimize_training` method basically clones the model to create a training model for compression, wrapping compressible layers by the training wrapper to create training weights. The number of the method calling is (# of compressible weights).
392396
393397
1. `fake_decompress`
394398
<p align="center">
395399
<img src=20201221-tfmot-compression-api/fake_decompress.png />
396400
</p>
401+
397402
```python
398403
training_model.fit(x_train, y_train, epochs=2)
399404
```
405+
400406
`fake_decompress` is called when the training model for the compression algorithm is training. Usually this method function is a part of the training model. It recovers the original weight from the training weights, and should be differentiable. This method enables you to use the original graph to compute the model output, but train the training weights of the training model. For each training step, this method is called for every compressible weight. The number of the method calling is (# of compressible weights) * (training steps).
401407
402408
1. `compress`
403409
<p align="center">
404410
<img src=20201221-tfmot-compression-api/compress.png />
405411
</p>
412+
406413
```python
407414
compressed_model = optimize_inference(training_model, params)
408415
```
416+
409417
`compress` is called when we convert the training model to the compressed model. The number of the method calling is (# of compressible weights).
410418
411419
1. `decompress`
412420
<p align="center">
413421
<img src=20201221-tfmot-compression-api/decompress.png />
414422
</p>
423+
415424
```python
416425
compressed_model.evaluate(x_test, y_test, verbose=2)
417426
```
427+
418428
`decompress` is called when we do inference on a compressed model. Usually this method function is a part of a compressed model. This method decompresses the weight that can be used on the original graph for each compressible weight. Basically the number of this method called is (# of compressible weights) * (# of inference). To improve performance, the output value of this method can be cached.
419429
420430
## Questions and Discussion Topics

0 commit comments

Comments
 (0)