Comments (12)
@Ariel-JUAN
You can load the checkpoint file, mark input and output tensors with tf.add_to_collection
, and save the graph to checkpoint files, so that the model conversion script can recognize them.
from pocketflow.
As far as I know, you cannot using post-training quantization to convert a model with 32-bit floating-point weights into its counterpart with 8-bit fixed-point weights in the *.pb format. It is only provided in the TF-Lite module: tf.contrib.lite.TocoConverter
.
You can try to quantize a model with our UniformQuantTFLearner
with quantization-aware training, and then export the resulting model to a *.pb file for deployment.
BTW, are you sure that 8-bit quantized model can bring acceleration on a GPU? We have only tested it on mobile devices, where TF-Lite has provided special optimization for low-precision operations.
from pocketflow.
The only way to find out is to benchmark on the target H/w
from pocketflow.
Sorry, we currently do not have enough time to complete this benchmark, due to limited resources. Could you please benchmark this by yourself?
from pocketflow.
@jiaxiang-wu
Hi, I use python tools/conversion/export_quant_tflite_model.py --model_dir ./models --input_coll inputs --output_coll outputs --quantize True to do the quantization, but I am not sure what does inputs and outputs mean? What should I put in?
from pocketflow.
The input_coll
and output_coll
arguments are used to locate the input and output tensors in the original / compressed model. For instance, in DisChnPrunedLearner
, we mark the input and output tensors with:
# add input & output tensors to certain collections
tf.add_to_collection('images_final', images)
tf.add_to_collection('logits_final', logits)
In this case, we use --input_coll images_final --output_coll logits_final
(which are default values of these two arguments) to locate input and output tensors.
https://github.com/Tencent/PocketFlow/blob/master/learners/discr_channel_pruning/learner.py#L328
from pocketflow.
@jiaxiang-wu
Hi, thanks for replying.
There is a model which doesn't specify the input and output tensors using tf.add_to_collection operation. Can't I get the quantized model?
Can I just specify the input and output tensor without using tf.get_collection?
from pocketflow.
@jiaxiang-wu
Hi, I did as you told me and it worked~
But I got confused again. Why use export_pb_tflite_model to operate pb file twice? After that I got a model_original.pb and model_transformed.pb?
My original model.ckpt.data is about 255M, and meta is about 255M. The model_original.pb is about 255M but the model_transformed.pb is about 400M.
It is normal? I thought the quantized model should be smaller than it used to be.....
from pocketflow.
Which model conversion script are you using? And, which model compression method (or "learner") are you using to obtain the compressed model?
from pocketflow.
@jiaxiang-wu
The command is python tools/conversion/export_pb_tflite_models.py --model_dir ./models --input_coll input --output_coll output.
from pocketflow.
This model conversion script is used to convert channel pruned models, rather than quantized models, to TF-Lite models. If the compressed model you provided is not channel pruned, then "model_transformed.pb" and "model_transformed.tflite" models may be larger due to newly inserted 1x1 convolutional layers.
from pocketflow.
@jiaxiang-wu
Thanks.
from pocketflow.
Related Issues (20)
- cifar10_channel pruned 的示例,通道剪枝(channel_pruning) 导出修改了计算图之后,速度比之前的更慢了! HOT 1
- Can the compression method provided by pocketflow be applied to MASK R-CNN? HOT 1
- QQ group HOT 1
- 我可以只用模型压缩部分么?
- TypeError: forward_train() missing 1 required positional argument: 'objects'
- Missing 1 required positional argument in constructor : data_format
- Download Pretrain Model But Get 502 Bad Gateway Error HOT 1
- You must feed a value for placeholder tensor 'model/input_1' with dtype float and shape [?,160,240,1]
- Question about export_chn_pruned_tflite_model.py HOT 1
- TF Version compatibility HOT 2
- Failed to create session
- Is it possible to compress the keras model with Pocket Flow
- Question about UniformLearner HOT 2
- Default tensorboard log output is huge
- FRCNN with VOC: Cannot batch tensors with different shapes in component 1.
- IndexError: list index out of range HOT 3
- Other issues:
- auto 通道裁剪问题
- test
- TF-Plus for Multi-GPU Training
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pocketflow.