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
212
|
11
try interpreter.invoke()
outputTensor = try interpreter.output(at: 0)
张量将输出一个包含两个值的数组,一个用于负面情绪,一个用于积极情绪。这些值介
0 1 之间,因此你需要将数组强制转换为
Float32
以访问它们:
let resultsArray = outputTensor.data
let results: [Float32] =
[Float32](unsafeData: resultsArray) ?? []
现在访问值相对容易了(终于!,读取数组中的前两项即可:
let negativeSentimentValue = results[0]
let positiveSentimentValue = results[1]
然后可以处理这些值,或者简单地输出,就像我在这个应用程序中所做的,你可以在图 11-7
中看到这一点。
11.5
总结
将来自 iOS TensorFlow 的机器学习模型与 Swift 结合使用,需要你在数据加载到模型
中以获取推理然后解析它时,获得相当低的级别并管理内存进出。在本章中,你探讨了
与图像相关的问题,你必须从底层图像中切出红色、绿色和蓝色的通道字节,将它们归
一化,并使用不安全数据缓冲区将它们写出为浮点值,然后加载到 TensorFlow Lite
释器。你还看到了如何解析模型的输出
以及为什么理解模型架构至关重要,在本例
中,模型架构有 5 个输出神经元 ...
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