Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
白麟_嗷呜
apachecn-dl-zh
提交
3122283e
A
apachecn-dl-zh
项目概览
白麟_嗷呜
/
apachecn-dl-zh
与 Fork 源项目一致
Fork自
OpenDocCN / apachecn-dl-zh
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apachecn-dl-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3122283e
编写于
12月 10, 2020
作者:
W
wizardforcel
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
2020-12-10 17:34:48
上级
929f8d5c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
15 deletion
+15
-15
new/intel-mobi-proj-tf/10.md
new/intel-mobi-proj-tf/10.md
+6
-6
new/intel-mobi-proj-tf/11.md
new/intel-mobi-proj-tf/11.md
+9
-9
未找到文件。
new/intel-mobi-proj-tf/10.md
浏览文件 @
3122283e
...
...
@@ -109,7 +109,7 @@ pip install keras
![](
img/99dc16a9-52c9-4adf-bd8f-1a244504de79.png
)
图 10.1:
The first layers of the deep residual network
图 10.1:
深度残差网络的第一层
值得注意的是,神经网络称为残差网络(ResNet),由 Microsoft 于 2015 年在 ImageNet 和 COCO 2015 竞赛的获奖作品中引入。 在 ResNet 中,使用身份映射(图 10.1 右侧的箭头)可避免在网络越深时出现更高的训练错误。 有关 ResNet 的更多信息,您可以查看原始论文
[
《用于图像识别的深度残差学习》
](
https://arxiv.org/pdf/1512.03385v1.pdf
)
, 以及博客
[
《了解深度残差网络》
](
https://blog.waya.ai/deep-residual-learning-9610bb62c355
)
- 一个简单的模块化学习框架,它重新定义了构成最新技术的内容。
...
...
@@ -117,7 +117,7 @@ pip install keras
![](
img/e3383760-5f06-4d10-a903-8978f41281de.png
)
图 10.2:
The last layers of the deep resnet
图 10.2:
深度 Resnet 的最后一层
在本节的最后部分,您将看到一些使用 Keras API 的 Python 代码片段,该片段对 ResNet 有着很好的支持,以构建这样的网络。 现在让我们让这些模型首先互相对抗,然后与我们一起对抗,看看这些模型有多好。
...
...
@@ -380,7 +380,7 @@ Couldn't load model: Invalid argument: No OpKernel was registered to support Op
![](
img/a0639a2a-55f3-485a-92cd-4ffdc99b398c.png
)
图 10.3:
Showing the AlphaZero iOS app in Xcode
图 10.3:
在 Xcode 中显示 AlphaZero iOS 应用
我们只需要使用三个 UI 组件:
...
...
@@ -826,13 +826,13 @@ int winners[69][4] = {
![](
img/fa949c2a-3114-4a56-9041-9acb069b1ff4.png
)
图 10.4:
Playing with Connect4 on iOS
图 10.4:
在 iOS 上玩 Connect4
使用 AI 玩一些游戏,图 10.5 显示了一些可能的最终游戏:
![](
img/1e45df24-e772-462b-aef9-67c8f49bed67.png
)
图 10.5:
Some game results of Connect4 on iOS
图 10.5:
iOS 上 Connect4 的一些游戏结果
在我们暂停之前,让我们快速看一下使用该模型并玩游戏的 Android 代码。
...
...
@@ -1317,7 +1317,7 @@ void softmax(float vals[], int count) {
![](
img/2d40ca7c-5d3d-4586-9034-2b2ae1c71ecb.png
)
图 10.6:
Showing the game board and some results on Android
图 10.6:
在 Android 上显示游戏板和一些结果
当您使用前面的代码在 iOS 和 Android 上玩游戏时,很快就会发现该模型返回的策略并不强大-主要原因是 MCTS 没有出现在这里,由于范围限制,不会与深度神经网络模型一起使用。 强烈建议您自己研究和实现 MCTS,或者在源代码存储库中使用我们的实现作为参考。 您还应该将网络模型和 MCTS 应用于您感兴趣的其他游戏-毕竟,AlphaZero 使用了通用 MCTS 和无领域知识的自我强化学习,从而使超人学习轻松移植到其他问题领域。 通过将 MCTS 与深度神经网络模型结合,您可以实现 AlphaZero 所做的事情。
...
...
new/intel-mobi-proj-tf/11.md
浏览文件 @
3122283e
...
...
@@ -118,7 +118,7 @@ target 'HelloTFLite'
![](
img/b4b1750b-cc97-42f8-a032-226b595d7e46.png
)
图 11.1:
A new Xcode iOS project using the TensorFlow Lite pod
图 11.1:
使用 TensorFlow Lite Pod 的新 Xcode iOS 项目
我们仅向您展示如何在 iOS 应用中使用 TensorFlow Lite Pod。 还有另一种将 TensorFlow Lite 添加到 iOS 的方法,类似于构建自定义 TensorFlow Mobile iOS 库的过程,我们在前几章中已经做过很多次了。 有关如何构建自己的自定义 TensorFlow Lite iOS 库的更多信息,请参阅
[
以下位置的文档
](
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/g3doc/ios.md
)
。
...
...
@@ -166,19 +166,19 @@ NSString* RunInferenceOnImage() {
![](
img/8df9836e-fbf9-4caf-97af-7d415b6dc5bb.png
)
图 11.2:T
he TensorFlow Mobile (left) and Lite code of loading and processing the image input
图 11.2:T
ensorFlow Mobile(左)和 Lite 代码,用于加载和处理图像输入
7.
在调用
`GetTopN`
辅助方法以获取前
`N`
个分类结果之前,调用
`Interpreter`
上的
`Invoke`
方法运行模型,并调用
`typed_out_tensor`
方法以获取模型的输出。 TensorFlow Mobile 和 Lite 之间的代码差异如图 11.3 所示:
![](
img/c3e31c5c-775f-4af8-a000-d8d65f75f657.png
)
图 11.3:
The TensorFlow Mobile (left) and Lite code of running the model and getting the output
图 11.3:
运行模型并获取输出的 TensorFlow Mobile(左)和 Lite 代码
8.
以类似于 HelloTensorFlow 中方法的方式实现
`GetTopN`
方法,对于 TensorFlow Lite 使用
`const float* prediction`
类型而不是对于 TensorFlow Mobile 使用
`const Eigen::TensorMap<Eigen::Tensor<float, 1, Eigen::RowMajor>, Eigen::Aligned>& prediction`
。 TensorFlow Mobile 和 Lite 中
`GetTopN`
方法的比较如图 11.4 所示:
![](
img/0f0c6dc7-939f-4b15-9542-c56a9f3f427f.png
)
图 11.4:
The TensorFlow Mobile (left) and Lite code of processing the model output to return the top results
图 11.4:
处理模型输出以返回最高结果的 TensorFlow Mobile(左)和 Lite 模型代码
9.
如果值大于阈值(设置为
`0.1f`
),则使用简单的
`UIAlertController`
显示带有 TensorFlow Lite 模型返回的置信度值的最佳结果:
...
...
@@ -200,7 +200,7 @@ NSString* RunInferenceOnImage() {
![](
img/5568ba52-1f2e-4968-b6d5-5a1d33061c46.png
)
图 11.5:
The test image and model inference result
图 11.5:
测试图像和模型推断结果
这就是您可以在新的 iOS 应用程序中使用预构建的 MobileNet TensorFlow Lite 模型的方式。 现在让我们看看如何使用经过重新训练的 TensorFlow 模型。
...
...
@@ -331,7 +331,7 @@ bazel-bin/tensorflow/contrib/lite/toco/toco \
![
](
img/9df4ffa8-cd63-4b4c-a728-47cba1394711.png
)
图 11.6:
New Android app using TensorFlow Lite and the prebuilt MobileNet image classification model
图 11.6:
使用 TensorFlow Lite 和预构建的 MobileNet 图像分类模型的新 Android 应用
5.
像以前一样,在
`activity_main.xml`
中添加
`ImageView`
和
`Button`
,然后在
`MainActivity.java`
的
`onCreate`
方法中,将
`ImageView`
设置为测试图像的内容,然后单击
`Button`
的侦听器以启动新线程,并实例化名为
`classifier`
的
`ImageClassifier`
实例:
...
...
@@ -539,7 +539,7 @@ coreml_model.save("HouseSVM.mlmodel")
![](
img/aaa2a1dd-d7f2-4fbc-8e70-3e6041ddda6e.png
)
图 11.7:
Showing the Swift iOS project and the Linear Regression Core ML model
图 11.7:
显示 Swift iOS 项目和线性回归 Core ML 模型
其他
`HouseSVM.mlmodel`
模型 看起来完全一样,只是机器学习模型名称和模型类从
`HouseLR`
更改为
`HouseSVM`
。
...
...
@@ -606,7 +606,7 @@ coreml_model.save("Stock.mlmodel")
![](
img/fdf48153-937d-4066-9dd3-cc13ce841e6e.png
)
图 11.8:
Showing the stock prediction Core ML model converted from Keras and TensorFlow in an Objective-C app
图 11.8:
在 Objective-C 应用中显示从 Keras 和 TensorFlow 转换而来的股票预测 Core ML 模型
使用 coremltools 生成模型的 Core ML 格式的另一种方法是,首先将 Keras 构建的模型保存为 Keras HDF5 模型格式,这是我们在第 10 章,“构建类似 AlphaZero 的移动游戏应用程序”中,在转换为 AlphaZero TensorFlow 检查点文件之前使用的格式。 为此,只需运行
`model.save('stock.h5')`
。
...
...
@@ -624,7 +624,7 @@ coreml_model.save('Stock.mlmodel')
![](
img/b77107fa-7de7-4602-84d1-d4c5b01c6efc.png
)
图 11.9:
Showing the stock prediction Core ML model converted from Keras and TensorFlow in a Swift app
图 11.9:
在 Swift 应用中显示从 Keras 和 TensorFlow 转换而来的股票预测 Core ML 模型
要在 Objective-C 中使用该模型,请创建具有指定数据类型和形状的
`Stock`
对象和
`MLMultiArray`
对象,然后使用一些输入数据填充数组对象,并使用
`StockInput`
调用
`predictionFromFeatures`
方法 用
`MLMultiArray`
数据初始化的实例:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录