【Google量化】Mobilenet TensorFlow-Slim

本文介绍了Google 2018年的CVPR论文,探讨了用于高效整数算术仅推断的神经网络量化技术。文章详细讲解了CNN量化,特别是针对MobileNet V1的实现,包括训练过程、模型转换和量化工具的使用,以实现更高效的设备端推理。
摘要由CSDN通过智能技术生成

最近在做量化相关的工作,在老师的推荐下看了这篇文章,这篇文章是google2018新的作品,非常良心,讲解非常详细,而且有代码可以work。

一、参考文献

Quantization and Training of Neural Networks for Efficient Integer-Arithmetic-Only Inference

The rising popularity of intelligent mobile devices and the daunting computational cost of deep learning-based models call for efficient and accurate on-device inference schemes. We propose a quantization scheme that allows inference to be carried out using integer-only arithmetic, which can be implemented more efficiently than floating point inference on commonly available integer-only hardware. We also co-design a training procedure to preserve end-to-end model accuracy post quantization. As a result, the proposed quantization scheme improves the tradeoff between accuracy and on-device latency. The improvements are significant even on MobileNets, a model family known for run-time efficiency, and are demonstrated in ImageNet classification and COCO detection on popular CPUs.

文章讲解:

Google CVPR 2018论文:CNN量化技术

Additionally, the minimum and maximum values for activations are determined during training. This allows a model trained with quantization in the loop to be converted to a fixed point inference model with little effort, eliminating the need for a separate calibration step.

此外,激活的最小值和最大值在训练期间确定。这使得在循环中用量化训练的模型可以毫不费力地转换成固定点推断模型,从而不需要单独的校准步骤。(校准是为了获得参数的范围)


二、具体实现

github 代码:

https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet_v1.md

The linked model tar files contain the following:

  • Trained model checkpoints:

mobilenet_v1_1.0_224.ckpt.data-00000-of-00001(保存变量及其取值)

mobilenet_v1_1.0_224.ckpt.index

mobilenet_v1_1.0_224.ckpt.meta(保存图结构)

  • Eval graph text protos (to be easily viewed) :mobilenet_v1_1.0_224_eval.pbtxt
  • Frozen trained models:mobilenet_v1_1.0_224_frozen.pb(模型大小:17173742
  • Info file containing input and output information:mobilenet_v1_1.0_224_info.txt
  • Converted TensorFlow Lite flatbuffer model:mobilenet_v1_1.0_224.tflite(模型大小:4276000

Note that

  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
### 回答1: `tensorflow-directml` 是使用 Microsoft DirectML 在 Windows 上加速 TensorFlow 执行的程序。它可以提高 TensorFlow 在 Windows 平台上的性能。 ### 回答2: TensorFlow-DirectML是一种使用DirectML快速进行深度学习计算的TensorFlow后端。DirectML是微软在Windows平台上推出的一种针对GPU的机器学习推理引擎,它充分利用了显卡的并行计算能力,提高了深度学习计算的速度和效率。 使用TensorFlow-DirectML可以在支持DirectML的硬件上运行TensorFlow模型,无需依赖传统的CUDA库。这一特点使得TensorFlow-DirectML更具灵活性和适用性,能够更加方便地部署和运行深度学习模型。 TensorFlow-DirectML的优势在于它能够以较低的延迟和更高的性能运行深度学习模型。这得益于DirectML引擎对硬件的直接访问,以及它对于GPU并行计算的有效利用。相比于传统的CPU计算,TensorFlow-DirectML能够显著提升深度学习模型的推理速度和效率。 另外,TensorFlow-DirectML还支持对模型进行优化、量化压缩,以进一步提高模型运行的效率和性能。它提供了一系列优化工具和API,使开发人员能够更加灵活地定制和优化他们的深度学习模型。 总的来说,TensorFlow-DirectML是一种基于DirectML的TensorFlow后端,它能够充分利用GPU的并行计算能力,提高深度学习模型的推理速度和效率。它的优势在于低延迟、高性能,并且支持模型优化和定制,使得开发人员能够更加方便地部署和运行深度学习模型。 ### 回答3: TensorFlow-DirectML是一个开源的深度学习框架,它是基于TensorFlow的DirectML后端。DirectML是微软开发的一种高性能、低延迟的深度学习推理引擎。 使用TensorFlow-DirectML,我们可以将深度学习模型部署到支持DirectML的硬件设备上,例如Windows 10和DirectX 12兼容的设备。TensorFlow-DirectML通过利用DirectML的硬件加速功能,提供了更快的推理性能,并且可以在低成本的硬件上运行深度学习模型。 TensorFlow-DirectML还提供了一些特殊优化,例如通过将计算操作从CPU转移到GPU以减少计算延迟,并使用Tensor Core等硬件特性来加速矩阵乘法计算等操作。同时,它还允许开发人员在TensorFlow中使用DirectML的功能,例如使用DirectML的低精度数值计算功能来加速模型推理过程。 TensorFlow-DirectML在使用上与传统的TensorFlow非常相似,开发人员可以使用相同的API和工作流程来构建和训练深度学习模型。一旦完成模型的训练,我们可以使用TensorFlow-DirectML将模型部署到DirectML支持的设备上进行推理,从而实现高性能的实时预测。 总之,TensorFlow-DirectML是一个基于DirectML后端的深度学习框架,通过利用DirectML的硬件加速功能,它可以提供更快的推理性能和更低的延迟。通过TensorFlow-DirectML,开发人员可以轻松地将深度学习模型部署到支持DirectML的设备上,并利用DirectML的功能来加速模型的推理过程。
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值