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
iOS
中使用自定义模型
|
203
所以现在你可以逐字节地遍历缓冲区数据。每个第 4 个都是 alpha 通道部分,因此你可
以忽略它。否则,你可以读取该字节,将其值除以 255 以对其进行归一化,然后将归一
化后的值存储在当前索引处的
rgbBytes
中:
var index = 0
for component in bufferData.enumerated() {
let offset = component.offset
let isAlphaComponent = (offset % 4) == 3
guard !isAlphaComponent else { continue }
rgbBytes[index] = Float(component.element) / 255.0
index += 1
}
现在你有了归一化字节序列,对于解释器来说,它看起来像一个包含图像的张量,你可
以将其作为
Data
返回,如下所示:
return rgbBytes.withUnsafeBufferPointer(Data.init)
下一步是将这个
Data
对象传递给解释器并得到一个推理结果。
11.2.6
6
步:获取张量的推理
此时,我们已将图像中的数据格式化为
Float
,包含红色、绿色和蓝色通道的
Data
,其
中包含每个像素每个通道的归一化数据。当解释器读取此数据时,它会将其识别为输入
张量并逐个浮点地读取它。首先,让我们初始化解释器并为输入和输出张量分配内存。
你会在应用程序的
getLabelForData ...
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