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
|
137
8.3.3
超越基础
这个例子非常简单
你有一个模型,它接受一个输入值并提供一个输出值。这两个都
是浮点数,需要 4 个字节来存储,因此你可以创建每个只有 4 字节的字节缓冲区,并
且知道它们包含单个值。因此,当使用更复杂的数据时,你必须努力将数据转换为模
型预期的格式,这需要你进行大量的工程设计。让我们看一个使用图像的例子。在第 9
章中,我们会看到 Model Maker,它是一个非常有用的工具,可以抽象出在 Android
iOS 上使用 TFLite 在常见场景中的复杂性
包括像这样的图像分类
但我认为它仍
然是一个有用的练习,可用于探索其原理,即当你走出常见场景时,如何管理模型内外
的数据!
例如,让我们从图 8-5 中的图像开始,这是一个简单的小狗图像,恰好是 395×500
素。这用在可以区分猫和狗的模型中。我不会详细介绍如何创建该模型,但本书的存储
库中有一个 notebook 为你做好了,还有一个用于处理推理的示例应用程序。你可以在
Chapter8_Lab2.ipynb
https://oreil.ly/mohak
)中找到训练代码,该应用程序名为“ cats_
vs_dogs”。
8-5
:要解释的小狗图像
你需要做的第一件事是将其大小调整为 224×224 像素,即训练模型时使用的图像尺寸。
这可以在 Android 中使用 Bitmap 库来完成。例如,你可以创建一个新的 224×224 位图:
val scaledBitmap ...
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