Skip to Content
移动端AI与ML应用开发:基于iOS和Android
book

移动端AI与ML应用开发:基于iOS和Android

by Laurence Moroney
January 2023
Intermediate to advanced
288 pages
6h 6m
Chinese
China Machine Press
Content preview from 移动端AI与ML应用开发:基于iOS和Android
更深入:了解
TensorFlow Lite
|
155
let results = [Float32](unsafeData: outputTensor.data) ?? []
如你所见,虽然这是一个更复杂的示例,但同样的设计模式仍然适用。你必须了解模型
的架构,以及原始输入和输出格式。然后,你必须按照模型预期的方式输入数据
通常意味着将原始字节写入缓冲区,或者至少使用数组进行模拟。然后,你必须读取来
自模型的原始字节流并创建一个数据结构来保存它们。从输出的角度来看,这几乎总是
像我们在本章中看到的那样
一个浮点数组。使用你已实现的辅助代码,你就大功告
成了!
我们将在第 11 章中更详细地研究这个例子。
8.5
探索模型优化
TensorFlow Lite 包含了使用代表性数据以及量化等过程来优化模型的工具。我们将在本
节中探讨这些。
8.5.1
量化
量化的想法来自理解模型中的神经元默认使用 float32 作为表示,但它们的值通常落在比
float32 范围小得多的范围内,以图 8-19 为例。
8-19
:量化值
在这种情况下,图表底部是特定神经元可能具有的可能值的直方图。它们被归一化,
所以分布在 0 附近,但最小值远大于 float32 的最小值,最大值远小于 float32 的最大
值。如果不是拥有所有这些“空白空间”,而是可以将直方图转换为更小的范围,比
–127 127,并相应地映射值,那会怎样?请注意,这样做,你将显著减少可以表示
的可能值的数量,因此你将面临精度损失的风险。对这种方法的研究表明,虽然可能会 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

人工智能驱动的商业智能

人工智能驱动的商业智能

Tobias Zwingmann
Lua游戏AI开发指南

Lua游戏AI开发指南

Posts & Telecom Press, David Young
人工智能技术与大数据

人工智能技术与大数据

Posts & Telecom Press, Anand Deshpande, Manish Kumar

Publisher Resources

ISBN: 9787111713081