谷歌中国开发者社区 (GDG)
  • 主页
  • 博客
    • Android
    • Design
    • GoogleCloud
    • GoogleMaps
    • GooglePlay
    • Web
  • 社区
    • 各地社区
    • 社区历史
    • GDG介绍
    • 社区通知
  • 视频
  • 资源
    • 资源汇总
    • 精选视频
    • 优酷频道

Train and deploy state-of-the-art mobile image classification models via Cloud TPU

2019-04-27adminGoogleCloudNo comments

Source: Train and deploy state-of-the-art mobile image classification models via Cloud TPU from Google Cloud

As organizations use machine learning (ML) more frequently in mobile and embedded devices, training and deploying small, fast, and accurate machine learning models becomes increasingly important. To help accelerate this process, we’ve published open-source Cloud TPU models to enable you and your data science team to train state-of-the-art mobile image classification models faster and at a lower cost.

For many IoT-focused businesses, it’s also essential to optimize both latency and accuracy, especially on low power, resource-constrained devices. By leveraging a novel, platform-aware neural architecture search framework (MnasNet), we identified a model architecture that can outperform the previous state-of-the-art MobileNetV1 and MobileNetV2 models that were carefully built by hand. You can find a comparison between MnasNet and MobileNetV2 below:

mnasnet vs mobilenetv2.png

This new MnasNet model runs nearly 1.8x faster inference speed (or 55% less latency) than the corresponding MobileNetV2 model and still maintains the same ImageNet top-1 classification accuracy.

How to train MnasNet on Cloud TPU

We specifically designed and optimized MNasNet to train as fast as we could make it on Cloud TPUs. The MnasNet model training source code is now the latest available in the TensorFlow TPU GitHub repository. Using this code, you can benefit from both low training cost and fast inference speed when you train MnasNet on Cloud TPUs and export the trained model for deployment.

If you have not yet experimented with training models on Cloud TPUs, you might want to begin by following the QuickStart guide. Once you are up and running with Cloud TPUs, you can begin training an MnasNet model by executing a command of this form:

The model processes training data in TFRecord format, which can be created from input image collections via TensorFlow’s Apache Beam pipeline tool. You can find more details on how to use Cloud TPUs to train MnasNet in our tutorial.

To help you further tune your MnasNet model, we have published additional notes about our implementation along with a variety of suggested tuning parameters to accommodate different classification latency requirements.

How you can deploy via SavedModel or TensorFlow Lite

You can easily deploy the models trained on Cloud TPUs to a variety of different platforms and devices. We have published pre-trained SavedModel files (mnasnet-a1 and mnasnet-b1) from ImageNet training runs to help you get started: you can use this MnasNet Colab to experiment with these pre-trained models interactively.

You can easily deploy your newly trained model by exporting it to TensorFlow Lite. You can convert an exported saved model into a *.tflite file with the following code:

Next, you can optionally apply post-training quantization, a common technique that reduces the model size while also providing up to 3x lower latency. These improvements are a result of smaller word sizes that enable faster computation and more efficient memory usage. To quantize 32-bit floating point numbers into more efficient 8-bit integers, add the following code:

The open-source implementation provided in the Cloud TPU repository implements saved model export, TensorFlow Lite export, and TensorFlow Lite’s post-training quantization by default. The code also includes a default serving input function that decodes and classifies JPEG images: if your application requires custom input preprocessing, you should consider modifying this example to perform your own input preprocessing (for serving or for on-device deployment via TensorFlow Lite).

With this new open source MnasNet implementation for Cloud TPU, it is easier and faster than ever before to train a state-of-the-art image classification model and deploy it on mobile and embedded devices. Check out our tutorial and Colab to get started.

Acknowledgements

Many thanks to the Googlers who contributed to this post, including Zak Stone, Xiaodan Song, David Shevitz, Barrett Williams, Russell Power, Adam Kerin, and Quoc Le.

除非特别声明,此文章内容采用知识共享署名 3.0许可,代码示例采用Apache 2.0许可。更多细节请查看我们的服务条款。

Tags: Cloud

Related Articles

Dr. Agarwal’s Eye Hospital sharpens its focus on the future of work with Chromebooks and Chromebases

2018-11-16admin

Deepening the Google Cloud and Red Hat collaboration with Red Hat Enterprise Linux 8 Certification

2019-05-07admin

How Standard Industries uses Google Cloud to power homes of the future

2019-10-22admin

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Recent Posts

  • Android Game SDK
  • From Sheets to Apps: how to curate and send content automatically with a simple script
  • Blockly Summit 2019: Rendering, Accessibility, and More!
  • Behind the counters, Chrome Enterprise and G Suite help Schnucks create faster grocery service
  • 5 favorite tools for improved log analytics

Recent Comments

  • admin on Using advanced Kubernetes autoscaling with Vertical Pod Autoscaler and Node Auto Provisioning
  • Martijn on Using advanced Kubernetes autoscaling with Vertical Pod Autoscaler and Node Auto Provisioning
  • Martijn on Using advanced Kubernetes autoscaling with Vertical Pod Autoscaler and Node Auto Provisioning
  • Chen Zhixiang on Concurrent marking in V8
  • admin on 使用 Android Jetpack 加快应用开发速度

Archives

  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • January 1970

Categories

  • Android
  • Design
  • Firebase
  • GoogleCloud
  • GoogleDevFeeds
  • GoogleMaps
  • GooglePlay
  • Google动态
  • iOS
  • Uncategorized
  • VR
  • Web
  • WebMaster
  • 社区
  • 通知

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

最新文章

  • Android Game SDK
  • From Sheets to Apps: how to curate and send content automatically with a simple script
  • Blockly Summit 2019: Rendering, Accessibility, and More!
  • Behind the counters, Chrome Enterprise and G Suite help Schnucks create faster grocery service
  • 5 favorite tools for improved log analytics
  • Networking cost optimization best practices: an overview
  • Shrinking the time to mitigate production incidents – CRE life lessons
  • Simplified data transformations for machine learning in BigQuery
  • Last month today: November on GCP
  • Flutter Interact – December 11 – create beautiful apps

最多查看

  • 如何选择 compileSdkVersion, minSdkVersion 和 targetSdkVersion (25,240)
  • Google 推出的 31 套在线课程 (22,403)
  • 谷歌招聘软件工程师 (22,286)
  • Seti UI 主题: 让你编辑器焕然一新 (13,813)
  • Android Studio 2.0 稳定版 (9,403)
  • Android N 最初预览版:开发者 API 和工具 (8,031)
  • 像 Sublime Text 一样使用 Chrome DevTools (6,304)
  • 用 Google Cloud 打造你的私有免费 Git 仓库 (6,071)
  • Google I/O 2016: Android 演讲视频汇总 (5,601)
  • 面向普通开发者的机器学习应用方案 (5,519)
  • 生还是死?Android 进程优先级详解 (5,218)
  • 面向 Web 开发者的 Sublime Text 插件 (4,335)
  • 适配 Android N 多窗口特性的 5 个要诀 (4,308)
  • 参加 Google I/O Extended,观看 I/O 直播,线下聚会! (3,619)
© 2019 中国谷歌开发者社区 - ChinaGDG