TensorFlow Lite
TensorFlow Lite简介
TensorFlowLite是Google在2017年5月推出的轻量级机器学习解决方案,主要针对移动端设备和嵌入式设备。针对移动端设备特点,TensorFlow Lite使用了诸多技术对内核进行了定制优化,预熔激活,量子化内核。TensorFlow Lite具有以下特征:
- 跨平台,核心代码由C++编写,可以运行在不同平台上;
- 轻量级,代码体积小,模型文件小,运行内存低;
- 支持硬件加速。
TensorFlow Lite架构
在server端完成模型的训练。通过TensorFlow Lite Converter转化成可以在手机端运行的.tflite格式的模型。TensorFlow Lite可以接入Android底层的神经网络的API从而进行硬件加速。另外TensorFlow团队宣布,已经与Apple达成合作,可以将TensorFlow平台训练出来的模型转化成可被Apple深度学习框架CoreML所解释运行的格式.mlmodel。这样一来开发者就有了更多的选择。他们既可以选择直接使用Google原生的tflite模型,也可以通过转化工具对接Apple的CoreML框架,更高效发挥Apple的硬件性能。 CoreML的转化工具可以从https://github.com/tf-coreml/tf-corem去下载。
TensorFlow Lite Demo
TensorFlow Lite提供了iOS和Android两个平台的Demo App。 这里以iOS平台为例,按照TensorFlow Lite提供的Tutorial完成配置。
首先安装xcode的工具链:
xcode-select --install
安装automake和libtool:
brew install automake
brew install libtool
运行脚本。脚本的作用是下载相关依赖。主要下载Ten