提交 1385931f 编写于 作者: W wizardforcel

2020-12-30 21:18:23

上级 b9ccd780
......@@ -53,15 +53,13 @@
## 下载示例代码文件
本书的代码包托管在 GitHub 上:
[本书的代码包托管在 GitHub 上](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
[https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras )
我们还从 [https://github.com/PacktPublishing/](https://github.com/PacktPublishing/) 提供了丰富的书籍和视频目录中的其他代码包。 去看一下!
我们还从[这里](https://github.com/PacktPublishing/)提供了丰富的书籍和视频目录中的其他代码包。 去看一下!
## 下载彩色图像
我们还提供本书中使用的彩色图像图像。 您可以在此处下载: [https://static.packt-cdn.com/downloads/9781838821654_ColorImages.pdf](https://static.packt-cdn.com/downloads/9787838821654_ColorImages.pdf)
我们还提供本书中使用的彩色图像图像。 [您可以在此处下载](https://static.packt-cdn.com/downloads/9787838821654_ColorImages.pdf)
## 使用约定
......@@ -144,11 +142,11 @@ python3 name-of-the-file-in-listing
**一般反馈**:给`feedback@packtpub.com`发送电子邮件,并在邮件主题中提及该书的标题。 如果您对本书的任何方面有疑问,请通过`questions@packtpub.com`向我们发送电子邮件。
**勘误表**:尽管我们已尽一切努力确保内容的准确性,但还是会发生错误。 如果您在本书中发现错误,请向我们报告,我们将不胜感激。 请访问 [http://www.packtpub.com/submit-errata](http://www.packtpub.com/submit-errata) ,选择您的图书,点击勘误提交表格链接,然后输入详细信息。
**勘误表**:尽管我们已尽一切努力确保内容的准确性,但还是会发生错误。 如果您在本书中发现错误,请向我们报告,我们将不胜感激。 请访问[这里](http://www.packtpub.com/submit-errata),选择您的图书,点击勘误提交表格链接,然后输入详细信息。
**盗版**:如果您在 Internet 上以任何形式遇到我们的作品的任何非法副本,请向我们提供位置地址或网站名称,我们将不胜感激。 请通过`copyright@packtpub.com`与我们联系,并提供材料链接。
**如果您有兴趣成为作者**:如果您有一个专业的话题并且对写作或撰写书籍感兴趣,请访问 [http://authors.packtpub .com](http://authors.packtpub.com)
**如果您有兴趣成为作者**:如果您有一个专业的话题并且对写作或撰写书籍感兴趣,请访问[这里](http://authors.packtpub.com)
## 评论
......
......@@ -25,7 +25,7 @@ Keras [1]是一个受欢迎的深度学习库,在撰写本文时有 370,000
我们选择`tf.keras`作为本书的首选工具,因为它是致力于加速深度学习模型实施的库。 这使得 Keras 非常适合我们想要实用且动手的时候,例如,当我们探索本书中的高级深度学习概念时。 由于 Keras 旨在加速深度学习模型的开发,培训和验证,因此在有人可以最大限度地利用图书馆之前,必须学习该领域的关键概念。
本书的所有示例都可以在 GitHub 的以下链接上找到: [https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
[本书的所有示例都可以在 GitHub 的以下链接上找到](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
`tf.keras`库中,各层之间就像乐高积木一样相互连接,从而形成了一个干净且易于理解的模型。 模型训练非常简单,只需要数据,大量训练和监控指标即可。
......@@ -71,7 +71,7 @@ $ sudo pip3 install tensorflow
$ sudo pip3 install tensorflow-gpu
```
无需安装 Keras,因为它已经是`tf2`中的软件包。 如果您不愿意在系统范围内安装库,强烈建议使用 Anaconda( [https://www.anaconda.com/distribution/](https://www.anaconda.com/distribution/)之类的环境。 除了具有隔离环境之外,Anaconda 发行版还安装了用于数据科学的常用第三方软件包,这些软件包对于深度学习是必不可少的。
无需安装 Keras,因为它已经是`tf2`中的软件包。 如果您不愿意在系统范围内安装库,强烈建议使用 [Anaconda](https://www.anaconda.com/distribution/) 之类的环境。 除了具有隔离环境之外,Anaconda 发行版还安装了用于数据科学的常用第三方软件包,这些软件包对于深度学习是必不可少的。
本书中提供的示例将需要其他软件包,例如`pydot``pydot_ng``vizgraph``python3-tk``matplotlib`。 在继续本章之前,我们需要安装这些软件包。
......@@ -87,7 +87,7 @@ $ python3
1e-07
```
本书没有涵盖完整的 Keras API。 我们将仅介绍解释本书中选定的高级深度学习主题所需的材料。 有关更多信息,请查阅 Keras 官方文档,该文档可在 [https://keras.io](https://keras.io)[https://www.tensorflow.org/guide/keras/overview [](https://www.tensorflow.org/guide/keras/overview)
本书没有涵盖完整的 Keras API。 我们将仅介绍解释本书中选定的高级深度学习主题所需的材料。 有关更多信息,请查阅 Keras 官方文档,该文档[这里](https://keras.io)[这里](https://www.tensorflow.org/guide/keras/overview)
在随后的部分中,将讨论 MLP,CNN 和 RNN 的详细信息。 这些网络将用于使用`tf.keras`构建简单的分类器。
......@@ -527,7 +527,7 @@ GD 通常不用于深度神经网络,因为遇到数百万个要训练的参
在该等式中,![](img/B14853_01_022.png)和![](img/B14853_01_023.png)分别是损耗函数的参数和梯度张量。 **g** 由损失函数的偏导数计算得出。 出于 GPU 优化的目的,建议最小批量大小为 2 的幂。 在建议的网络中,`batch_size = 128`
*公式 1.3.8* 计算最后一层参数更新。 那么,我们如何调整前几层的参数呢? 在这种情况下,应用微分链规则将导数传播到较低层并相应地计算梯度。 该算法在深度学习中称为**反向传播**。 反向传播的详细信息超出了本书的范围。 但是,可以在 [http://neuralnetworksanddeeplearning.com](http://neuralnetworksanddeeplearning.com) 找到很好的在线参考。
*公式 1.3.8* 计算最后一层参数更新。 那么,我们如何调整前几层的参数呢? 在这种情况下,应用微分链规则将导数传播到较低层并相应地计算梯度。 该算法在深度学习中称为**反向传播**。 反向传播的详细信息超出了本书的范围。 但是,可以在[这里](http://neuralnetworksanddeeplearning.com)找到很好的在线参考。
由于优化是基于微分的,因此得出损失函数的重要标准是它必须平滑或可微。 当引入新的损失函数时,这是要牢记的重要约束。
......@@ -951,7 +951,7 @@ Non-trainable params: 0
在许多深度神经网络中,更常使用 RNN 家族的其他成员。 例如,机器翻译和问答问题都使用了**长短期记忆****LSTM** )。 LSTM 解决了长期依赖或记住与当前输出相关的过去信息的问题。
与 RNN 或 SimpleRNN 不同,LSTM 单元的内部结构更为复杂。 *图 1.5.4* 显示了 LSTM 的示意图。 LSTM 不仅使用当前输入和过去的输出或隐藏状态,还引入了一个单元状态 **s** <sub style="font-style: bold;">t</sub> ,该状态将信息从一个单元传送到另一个单元。 单元状态之间的信息流由三个门控制 **f** <sub style="font-style: bold;">t</sub>**i** <sub style="font-style: bold;">t</sub>**q** <sub style="font-style: bold;">t</sub> 。 这三个门的作用是确定应保留或替换哪些信息,以及过去对当前单元状态或输出有贡献的信息量以及过去和当前的输入。 我们不会在本书中讨论 LSTM 单元内部结构的细节。 但是,可以在 [http://colah.github.io/posts/2015-08-Understanding-LSTMs](http://colah.github.io/posts/2015-08-Understanding-LSTMs) 上找到 LSTM 的直观指南。
与 RNN 或 SimpleRNN 不同,LSTM 单元的内部结构更为复杂。 *图 1.5.4* 显示了 LSTM 的示意图。 LSTM 不仅使用当前输入和过去的输出或隐藏状态,还引入了一个单元状态 **s** <sub style="font-style: bold;">t</sub> ,该状态将信息从一个单元传送到另一个单元。 单元状态之间的信息流由三个门控制 **f** <sub style="font-style: bold;">t</sub>**i** <sub style="font-style: bold;">t</sub>**q** <sub style="font-style: bold;">t</sub> 。 这三个门的作用是确定应保留或替换哪些信息,以及过去对当前单元状态或输出有贡献的信息量以及过去和当前的输入。 我们不会在本书中讨论 LSTM 单元内部结构的细节。 但是,可以在[这个页面](http://colah.github.io/posts/2015-08-Understanding-LSTMs)上找到 LSTM 的直观指南。
`LSTM()`层可以用作`SimpleRNN()`的嵌入式替代。 如果 LSTM 对于手头的任务过于苛刻,则可以使用更简单的版本,称为**门控循环单元****GRU** )。 GRU 通过将单元状态和隐藏状态组合在一起来简化 LSTM。 GRU 还将门数量减少了一个。 `GRU()`功能也可以用作`SimpleRNN()`的直接替代品。
......@@ -977,6 +977,5 @@ Non-trainable params: 0
# 7.参考
1. 弗朗索瓦·乔莱特。 凯拉斯(2015)。 [https://github.com/keras-team/keras](https://github.com/keras-team/keras)
1. LeCun,Yann,Corinna Cortes 和 C.J. Burges。 *MNIST 手写数字数据库*。 AT & T Labs [在线]。 可用: [http://yann.lecun.com/exdb/mnist2](http://yann.lecun.com/exdb/mnist2) (2010 年)。
\ No newline at end of file
1. `Chollet, François. Keras (2015). https://github.com/keras-team/keras.`
2. `LeCun, Yann, Corinna Cortes, and C. J. Burges. MNIST handwritten digit database. AT&T Labs [Online]. Available: http://yann.lecun.com/exdb/mnist2 (2010).`
\ No newline at end of file
......@@ -2,7 +2,7 @@
# 深度神经网络
在本章中,我们将研究深度神经网络。 这些网络在更具挑战性的数据集(如 ImageNet,CIFAR10( [https://www.cs.toronto.edu/~kriz/learning-features-2009-TR.pdf](https://www.cs.toronto.edu/~kriz/learning-features-2009-TR.pdf)和 CIFAR100。 为简洁起见,我们仅关注两个网络: **ResNet** [2] [4]和 **DenseNet** [5]。 尽管我们会更加详细,但重要的是花一点时间介绍这些网络。
在本章中,我们将研究深度神经网络。 这些网络在更具挑战性的数据集,如 ImageNet,[CIFAR10](https://www.cs.toronto.edu/~kriz/learning-features-2009-TR.pdf) 和 CIFAR100。 为简洁起见,我们仅关注两个网络: **ResNet** [2] [4]和 **DenseNet** [5]。 尽管我们会更加详细,但重要的是花一点时间介绍这些网络。
ResNet 引入了残差学习的概念,使残障学习能够通过解决深度卷积网络中消失的梯度问题(在第 2 节中讨论)来构建非常深的网络。
......@@ -298,7 +298,7 @@ print("\nTest accuracy: %.1f%%" % (100.0 * score[1]))
总结我们对功能 API 的了解。 我们应该花时间记住本章的重点是构建深度神经网络,特别是 ResNet 和 DenseNet。 因此,我们只讨论构建它们所需的功能性 API 材料,因为涵盖整个的 API 将超出本书的范围。 话虽如此,让我们继续讨论 ResNet。
有关功能 API 的其他信息,请阅读 [https://keras.io/](https://keras.io/)
有关功能 API 的其他信息,请阅读[这里](https://keras.io/)
# 2.深度残留网络(ResNet)
......@@ -547,7 +547,7 @@ ResNet 在 *n* 的各种值上的性能显示在*表 2.2.2* 中。
图 2.2.6:一个简单的数据扩充就是翻转原始图像
完整的代码可在 GitHub 上获得: [https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras。](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras.)
[完整的代码可在 GitHub 上获得](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
准确复制原始论文的实现通常很困难。 在本书中,我们使用了不同的优化器和数据扩充。 这可能会导致本书中所实现的`tf.keras` ResNet 和原始模型中的性能略有不同。
......@@ -890,11 +890,10 @@ DenseNet 完成了我们对深度神经网络的讨论。 与 ResNet 一起,
# 6.参考
1. 何开明等。 *深入整流器:在 ImageNet 分类*上超越人类水平的性能。 2015 年 IEEE 国际计算机视觉国际会议论文集( [https://www.cv-foundation.org/openaccess/content_iccv_2015/papers/He_Delving_Deep_into_ICCV_2015_paper.pdfspm=5176.100239.blogcont55892.28.pm8zm_He_D_V_D_V_D .pdf)](https://www.cv-foundation.org/openaccess/content_iccv_2015/papers/He_Delving_Deep_into_ICCV_2015_paper.pdf?spm=5176.100239.blogcont55892.28.pm8zm1&file=He_Delving_Deep_into_ICCV_2015_paper.pdf))。
2. 何开明等。 *用于图像识别的深度残差学习*。 IEEE 关于计算机视觉和模式识别的会议论文集,2016a( [http://openaccess.thecvf.com/content_cvpr_2016/papers/He_Deep_Residual_Learning_CVPR_2016_paper.pdf](http://openaccess.thecvf.com/content_cvpr_2016/papers/He_Deep_Residual_Learning_CVPR_2016_paper.pdf) )。
3. Karen Simonyan 和 Andrew Zisserman。 *用于大规模图像识别的超深度卷积网络*。 ICLR,2015 年( [https://arxiv.org/pdf/1409.1556/](https://arxiv.org/pdf/1409.1556/) )。
4. 何开明等。 深度残差网络中的*身份映射。 欧洲计算机视觉会议。 Springer International Publishing,2016b( [https://arxiv.org/pdf/1603.05027.pdf](https://arxiv.org/pdf/1603.05027.pdf) )。*
5. 高煌等。 *紧密连接的卷积网络*。 IEEE 计算机视觉和模式识别会议(2017 年 [http://openaccess.thecvf.com/content_cvpr_2017/papers/Huang_Densely_Connected_Convolutional_CVPR_2017_paper.pdf](http://openaccess.thecvf.com/content_cvpr_2017/papers/Huang_Densely_Connected_Convolutional_CVPR_2017_paper.pdf) )会议录。
6. 谢赛宁等。 *用于深度神经网络*的聚合残差转换。 计算机视觉和模式识别(CVPR),2017 IEEE Con​​ference on。 IEEE,2017 年[ [http://openaccess.thecvf.com/content_cvpr_2017/papers/Xie_Aggregated_Residual_Transformations_CVPR_2017_paper.pdf](http://openaccess.thecvf.com/content_cvpr_2017/papers/Xie_Aggregated_Residual_Transformations_CVPR_2017_paper.pdf) )。
1. Zagoruyko,Sergey 和 Nikos Komodakis。 “ *残差网络*。 arXiv 预印本 arXiv:1605.07146(2016)。
\ No newline at end of file
1. `Kaiming He et al. Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification. Proceedings of the IEEE international conference on computer vision, 2015 (https://www.cv-foundation.org/openaccess/content_iccv_2015/papers/He_Delving_Deep_into_ICCV_2015_paper.pdfspm=5176.100239.blogcont55892.28.pm8zm1&file=He_Delving_Deep_into_ICCV_2015_paper.pdf).`
1. `Kaiming He et al. Deep Residual Learning for Image Recognition. Proceedings of the IEEE conference on computer vision and pattern recognition, 2016a (http://openaccess.thecvf.com/content_cvpr_2016/papers/He_Deep_Residual_Learning_CVPR_2016_paper.pdf).`
1. `Karen Simonyan and Andrew Zisserman. Very Deep Convolutional Networks for Large-Scale Image Recognition. ICLR, 2015 (https://arxiv.org/pdf/1409.1556/).`
1. K`aiming He et al. Identity Mappings in Deep Residual Networks. European Conference on Computer Vision. Springer International Publishing, 2016b (https://arxiv.org/pdf/1603.05027.pdf).`
1. `Gao Huang et al. Densely Connected Convolutional Networks. Proceedings of the IEEE conference on computer vision and pattern recognition, 2017 (http://openaccess.thecvf.com/content_cvpr_2017/papers/Huang_Densely_Connected_Convolutional_CVPR_2017_paper.pdf).`
1. `Saining Xie et al. Aggregated Residual Transformations for Deep Neural Networks. Computer Vision and Pattern Recognition (CVPR), 2017 IEEE Conference on. IEEE, 2017 (http://openaccess.thecvf.com/content_cvpr_2017/papers/Xie_Aggregated_Residual_Transformations_CVPR_2017_paper.pdf).`
1. `Zagoruyko, Sergey, and Nikos Komodakis. "Wide residual networks." arXiv preprint arXiv:1605.07146 (2016).`
\ No newline at end of file
......@@ -890,4 +890,4 @@ plt.show()
# 6.参考
1. Ian Goodfellow 等:*深度学习*。 卷 1.剑桥:麻省理工学院出版社,2016 年( [http://www.deeplearningbook.org/](http://www.deeplearningbook.org/))。
\ No newline at end of file
1. `Ian Goodfellow et al.: Deep Learning. Vol. 1. Cambridge: MIT press, 2016 (http://www.deeplearningbook.org/).`
\ No newline at end of file
......@@ -21,9 +21,9 @@
可以在以下 YouTube 视频中看到 GAN 的高级功能:
* Progressive GAN [4]: [https://youtu.be/G06dEcZ-QTg](https://youtu.be/G06dEcZ-QTg)
* StyleGAN v1 [5]: [https://youtu.be/kSLJriaOumA](https://youtu.be/kSLJriaOumA)
* StyleGAN v2 [6]: [https://youtu.be/c-NJtV9Jvp0](https://youtu.be/c-NJtV9Jvp0)
* [Progressive GAN [4]](https://youtu.be/G06dEcZ-QTg)
* [StyleGAN v1 [5]](https://youtu.be/kSLJriaOumA)
* [StyleGAN v2 [6]](https://youtu.be/c-NJtV9Jvp0)
展示如何利用 GAN 产生逼真的面部的视频演示了它们的功能。 这个主题比我们之前看过的任何内容都先进得多。 例如,上面的视频演示了自动编码器无法轻松完成的事情,我们在*第 3 章**自动编码器*中介绍了这些内容。
......@@ -129,7 +129,7 @@ DCGAN 实施以下设计原则:
在对`strides = 2`进行两个`Conv2DTranspose`之后,特征图的大小将为 28 x 28 x *数量的过滤器*。 每个`Conv2DTranspose`之前都有批处理规范化和 ReLU。 最后一层具有*乙状结肠*激活,可生成 28 x 28 x 1 假 MNIST 图像。 将每个像素标准化为与[0,255]灰度级相对应的[0.0,1.0]。 *下面的清单 4.2.1* 显示了`tf.keras`中生成器网络的实现。 定义了一个函数来生成生成器模型。 由于整个代码的长度,我们将列表限制为正在讨论的特定行。
完整的代码可在 GitHub 上获得: [https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
[完整的代码可在 GitHub 上获得](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
*清单 4.2.1*`dcgan-mnist-4.2.1.py`
......@@ -778,10 +778,9 @@ python3 cgan-mnist-4.3.1.py --generator=cgan_mnist.h5 --digit=8
# 5.参考
1. 伊恩·古德费洛(Ian Goodfellow)。 *NIPS 2016 教程:生成对抗网络*。 arXiv 预印本 arXiv:1701.00160,2016( [https://arxiv.org/pdf/1701.00160.pdf](https://arxiv.org/pdf/1701.00160.pdf) )。
2. 亚历克·雷德福德,卢克·梅斯和苏米斯·金塔拉。 *使用深度卷积生成对抗网络*的无监督表示学习。 arXiv 预印本 arXiv:1511.06434,2015( [https://arxiv.org/pdf/1511.06434.pdf](https://arxiv.org/pdf/1511.06434.pdf) )。
3. Mehdi Mirza 和 Simon Osindero。 *条件生成对抗网*。 arXiv 预印本 arXiv:1411.1784,2014( [https://arxiv.org/pdf/1411.1784.pdf](https://arxiv.org/pdf/1411.1784.pdf) )。
4. Tero Karras 等。 *GAN 的逐步生长,以提高质量,稳定性和变异性*。 ICLR,2018( [https://arxiv.org/pdf/1710.10196.pdf](https://arxiv.org/pdf/1710.10196.pdf) )。
5. Tero Karras,Samuli Laine 和 Timo Aila。 *用于生成对抗网络*的基于样式的生成器体系结构。 IEEE 计算机视觉和模式识别会议论文集。 2019。
1. Tero Karras 等。 *分析和改善 StyleGAN* 的图像质量。 2019( [https://arxiv.org/abs/1912.04958](https://arxiv.org/abs/1912.04958) )。
\ No newline at end of file
1. `Ian Goodfellow. NIPS 2016 Tutorial: Generative Adversarial Networks. arXiv preprint arXiv:1701.00160, 2016 (https://arxiv.org/pdf/1701.00160.pdf).`
1. `Alec Radford, Luke Metz, and Soumith Chintala. Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks. arXiv preprint arXiv:1511.06434, 2015 (https://arxiv.org/pdf/1511.06434.pdf).`
1. `Mehdi Mirza and Simon Osindero. Conditional Generative Adversarial Nets. arXiv preprint arXiv:1411.1784, 2014 (https://arxiv.org/pdf/1411.1784.pdf).`
1. `Tero Karras et al. Progressive Growing of GANs for Improved Quality, Stability, and Variation. ICLR, 2018 (https://arxiv.org/pdf/1710.10196.pdf).`
1. `Tero Karras, , Samuli Laine, and Timo Aila. A Style-Based Generator Architecture for Generative Adversarial Networks. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 2019.`
1. `Tero Karras et al. Analyzing and Improving the Image Quality of StyleGAN. 2019 (https://arxiv.org/abs/1912.04958).`
\ No newline at end of file
......@@ -132,7 +132,7 @@ EMD 背后的想法是,它是为了确定概率分布 *p* <sub style="font-sty
由于 *D* <sub style="font-style: italic;">JS</sub> 是一个常数,因此 GAN 将没有足够的梯度来驱动![](img/B14853_05_049.png)。 我们还会发现 *D* <sub style="font-style: italic;">KL</sub> 或反向 *D* <sub style="font-style: italic;">KL</sub> 也不起作用。 但是,通过 *W(p* <sub style="font-style: italic;">数据</sub> *,p * <sub style="font-style: italic;"> g </sub> *)*,我们可以使平滑 通过梯度下降获得![](img/B14853_05_050.png)。 为了优化 GAN,EMD 或 Wasserstein 1 似乎是一个更具逻辑性的损失函数,因为在两个分布具有极小或没有重叠的情况下, *D* <sub style="font-style: italic;">JS</sub> 会失败。
为了帮助进一步理解,可以在以下位置找到有关距离函数的精彩讨论: [https://lilianweng.github.io/lil-log/2017/08/20/from-GAN-to-WGAN。 html。](https://lilianweng.github.io/lil-log/2017/08/20/from-GAN-to-WGAN.html.)
为了帮助进一步理解,可以在以下位置找到[有关距离函数的精彩讨论](https://lilianweng.github.io/lil-log/2017/08/20/from-GAN-to-WGAN.html)
在下一节中,我们将重点介绍使用 EMD 或 Wasserstein 1 距离函数来开发替代损失函数,以鼓励稳定训练 GAN。
......@@ -271,7 +271,7 @@ generator = gan.generator(inputs, image_size)
*清单 5.1.1* 突出显示了 RMSprop 优化器和 Wasserstein 损失函数的使用。 在训练期间使用*算法 5.1.1* 中的超参数。
完整的代码可在 GitHub 上获得: [https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
[完整的代码可在 GitHub 上获得](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
*清单 5.1.1*`wgan-mnist-5.1.2.py`
......@@ -1171,7 +1171,7 @@ python3 acgan-mnist-5.3.1.py --generator=acgan_mnist.h5 --digit=3
# 5.参考
1. 伊恩·古德费洛(Ian Goodfellow)等人:*生成对抗网络*。 神经信息处理系统的进展,2014 年( [http://papers.nips.cc/paper/5423-generative-adversarial-nets.pdf](http://papers.nips.cc/paper/5423-generative-adversarial-nets.pdf) )。
2. Martin Arjovsky,Soumith Chintala 和 LéonBottou: *Wasserstein GAN* 。 arXiv 预印本,2017( [https://arxiv.org/pdf/1701.07875.pdf](https://arxiv.org/pdf/1701.07875.pdf) )。
3. Xudong Mao 等:*最小二乘生成对抗网络*。 2017 IEEE 计算机视觉国际会议(ICCV)。 IEEE 2017( [http://openaccess.thecvf.com/content_ICCV_2017/papers/Mao_Least_Squares_Generative_ICCV_2017_paper.pdf](http://openaccess.thecvf.com/content_ICCV_2017/papers/Mao_Least_Squares_Generative_ICCV_2017_paper.pdf) )。
4. 奥古斯都·奥德纳(Augustus Odena),克里斯托弗·奥拉(Christopher Olah)和乔纳森·史伦斯(Jonathon Shlens)。 *使用辅助分类器 GAN* 的条件图像合成。 ICML,2017 年( [http://proceedings.mlr.press/v70/odena17a/odena17a.pdf](http://proceedings.mlr.press/v70/odena17a/odena17a.pdf) )。
\ No newline at end of file
1. `Ian Goodfellow et al.: Generative Adversarial Nets. Advances in neural information processing systems, 2014 (http://papers.nips.cc/paper/5423-generative-adversarial-nets.pdf).`
1. `Martin Arjovsky, Soumith Chintala, and Léon Bottou: Wasserstein GAN. arXiv preprint, 2017 (https://arxiv.org/pdf/1701.07875.pdf).`
1. `Xudong Mao et al.: Least Squares Generative Adversarial Networks. 2017 IEEE International Conference on Computer Vision (ICCV). IEEE 2017 (http://openaccess.thecvf.com/content_ICCV_2017/papers/Mao_Least_Squares_Generative_ICCV_2017_paper.pdf).`
1. `Augustus Odena, Christopher Olah, and Jonathon Shlens. Conditional Image Synthesis with Auxiliary Classifier GANs. ICML, 2017 (http://proceedings.mlr.press/v70/odena17a/odena17a.pdf).`
\ No newline at end of file
......@@ -126,7 +126,7 @@ inputs = [inputs, labels] + codes
`generator``discriminator`的构建器功能也在`lib`文件夹的`gan.py`中实现。
完整的代码可在 GitHub 上获得: [https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
[完整的代码可在 GitHub 上获得](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
*清单 6.1.1*`infogan-mnist-6.1.1.py`
......@@ -1363,6 +1363,5 @@ StackedGAN 生成器可以通过以下方式进行定性验证:
# 5.参考
1. Xi Chen 等: *InfoGAN:通过最大化生成对抗网络*的信息进行可解释的表示学习。 神经信息处理系统的进展,2016 年[ [http://papers.nips.cc/paper/6399-infogan-interpretable-representation-learning-in-information-maximizing-generative-adversarial-nets.pdf](http://papers.nips.cc/paper/6399-infogan-interpretable-representation-learning-by-information-maximizing-generative-adversarial-nets.pdf) )。
1. 黄勋等。 *堆叠式生成对抗网络*。 IEEE 计算机视觉和模式识别会议(CVPR)。 卷 2017 年 2 月 2 日( [http://openaccess.thecvf.com/content_cvpr_2017/papers/Huang_Stacked_Generative_Adversarial_CVPR_2017_paper.pdf](http://openaccess.thecvf.com/content_cvpr_2017/papers/Huang_Stacked_Generative_Adversarial_CVPR_2017_paper.pdf) )。
\ No newline at end of file
1. `Xi Chen et al.: InfoGAN: Interpretable Representation Learning by Information Maximizing Generative Adversarial Nets. Advances in Neural Information Processing Systems, 2016 (http://papers.nips.cc/paper/6399-infogan-interpretable-representation-learning-by-information-maximizing-generative-adversarial-nets.pdf).`
1. `Xun Huang et al. Stacked Generative Adversarial Networks. IEEE Conference on Computer Vision and Pattern Recognition (CVPR). Vol. 2, 2017 (http://openaccess.thecvf.com/content_cvpr_2017/papers/Huang_Stacked_Generative_Adversarial_CVPR_2017_paper.pdf).`
\ No newline at end of file
......@@ -193,9 +193,7 @@ CycleGAN 的总损耗变为:
编码器层由`Instance Normalization(IN)-LeakyReLU-Conv2D`组成,而解码器层由`IN-ReLU-Conv2D`组成。 编码器/解码器层的实现如清单 7.1.1 所示,而生成器的实现如清单 7.1.2 的*所示。*
完整的代码可在 GitHub 上找到:
[https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
[完整的代码可在 GitHub 上找到](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
**实例规范化****IN** )是每个数据(即 IN 是图像或每个功能的 BN)。 在样式转换中,重要的是标准化每个样本而不是每个批次的对比度。 IN 等于,相当于对比度归一化。 同时,BN 打破了对比度标准化。
......@@ -855,7 +853,7 @@ python3 cyclegan-7.1.1.py --cifar10_g_source=cyclegan_cifar10-g_source.h5
图 7.1.15:两个未对齐数据的不同域。 原始彩色照片可以在该书的 GitHub 存储库中找到,网址为 https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras/blob/master/chapter7-cross-domain-gan/README.md
我们可以重用上一节中讨论的 CycleGAN 的所有构建和训练功能,以执行样式转换。 唯一的区别是,我们必须添加用于加载 MNIST 和 SVHN 数据的例程。 SVHN 数据集可在 [http://ufldl.stanford.edu/housenumbers/中找到。](http://ufldl.stanford.edu/housenumbers/.)
我们可以重用上一节中讨论的 CycleGAN 的所有构建和训练功能,以执行样式转换。 唯一的区别是,我们必须添加用于加载 MNIST 和 SVHN 数据的例程。 SVHN 数据集可在[这个页面](http://ufldl.stanford.edu/housenumbers/)中找到。
我们介绍`mnist_svhn_utils.py`模块来帮助我们完成此任务。 *清单 7.1.7* 显示了针对跨域传输的 CycleGAN 的初始化和训练。
......@@ -984,11 +982,11 @@ python3 cyclegan-7.1.1.py --mnist_svhn_g_source=cyclegan_mnist_svhn-g_ source.h5
# 3.参考
1. Yuval Netzer 等人:*通过无监督特征学习*读取自然图像中的数字。 NIPS 深度学习和无监督特征学习研讨会。 卷 2011 年。第 2 号。2011 年[ [https://www-cs.stanford.edu/~twangcat/papers/nips2011_housenumbers.pdf](https://www-cs.stanford.edu/~twangcat/papers/nips2011_housenumbers.pdf) )。
2. Zhu-Jun-Yan et al .: *使用周期一致对抗网络*的不成对图像到图像的翻译。 2017 IEEE 计算机视觉国际会议(ICCV)。 IEEE,2017 年( [http://openaccess.thecvf.com/content_ICCV_2017/papers/Zhu_Unpaired_Image-To-Image_Translation_ICCV_2017_paper.pdf](http://openaccess.thecvf.com/content_ICCV_2017/papers/Zhu_Unpaired_Image-To-Image_Translation_ICCV_2017_paper.pdf) )。
3. Phillip Isola 等人:*使用条件对抗网络*进行图像到图像的翻译。 2017 IEEE 计算机视觉与模式识别会议(CVPR)。 IEEE,2017 年( [http://openaccess.thecvf.com/content_cvpr_2017/papers/Isola_Image-To-Image_Translation_With_CVPR_2017_paper.pdf](http://openaccess.thecvf.com/content_cvpr_2017/papers/Isola_Image-To-Image_Translation_With_CVPR_2017_paper.pdf) )。
4. Mehdi Mirza 和 Simon Osindero。 *条件生成对抗网*。 arXiv 预印本 arXiv:1411.1784,2014( [https://arxiv.org/pdf/1411.1784.pdf](https://arxiv.org/pdf/1411.1784.pdf) )。
5. Xudong Mao 等:*最小二乘生成对抗网络*。 2017 IEEE 计算机视觉国际会议(ICCV)。 IEEE,2017 年( [http://openaccess.thecvf.com/content_ICCV_2017/papers/Mao_Least_Squares_Generative_ICCV_2017_paper.pdf](http://openaccess.thecvf.com/content_ICCV_2017/papers/Mao_Least_Squares_Generative_ICCV_2017_paper.pdf) )。
6. 李传力和迈克尔·旺德(Michael Wand)。 *使用 Markovian 生成对抗网络*预先计算的实时纹理合成。 欧洲计算机视觉会议。 Springer,Cham,2016( [https://arxiv.org/pdf/1604.04382.pdf](https://arxiv.org/pdf/1604.04382.pdf) )。
7. Olaf Ronneberger,Philipp Fischer 和 Thomas Brox。 *U-Net:用于生物医学图像分割的卷积网络*。 医学图像计算和计算机辅助干预国际会议。 Springer,Cham,2015( [https://arxiv.org/pdf/1505.04597.pdf](https://arxiv.org/pdf/1505.04597.pdf) )。
8. Judy Hoffman 等: *CyCADA:周期一致的对抗域适应*。 arXiv 预印本 arXiv:1711.03213,2017( [https://arxiv.org/pdf/1711.03213.pdf](https://arxiv.org/pdf/1711.03213.pdf) )。
\ No newline at end of file
1. `Yuval Netzer et al.: Reading Digits in Natural Images with Unsupervised Feature Learning. NIPS workshop on deep learning and unsupervised feature learning. Vol. 2011. No. 2. 2011 (https://www-cs.stanford.edu/~twangcat/papers/nips2011_housenumbers.pdf).`
1. `Zhu-Jun-Yan et al.: Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks. 2017 IEEE International Conference on Computer Vision (ICCV). IEEE, 2017 (http://openaccess.thecvf.com/content_ICCV_2017/papers/Zhu_Unpaired_Image-To-Image_Translation_ICCV_2017_paper.pdf).`
1. `Phillip Isola et al.: Image-to-Image Translation with Conditional Adversarial Networks. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR). IEEE, 2017 (http://openaccess.thecvf.com/content_cvpr_2017/papers/Isola_Image-To-Image_Translation_With_CVPR_2017_paper.pdf).`
1. `Mehdi Mirza and Simon Osindero. Conditional Generative Adversarial Nets. arXiv preprint arXiv:1411.1784, 2014 (https://arxiv.org/pdf/1411.1784.pdf).`
1. `Xudong Mao et al.: Least Squares Generative Adversarial Networks. 2017 IEEE International Conference on Computer Vision (ICCV). IEEE, 2017 (http://openaccess.thecvf.com/content_ICCV_2017/papers/Mao_Least_Squares_Generative_ICCV_2017_paper.pdf).`
1. `Chuan Li and Michael Wand. Precomputed Real-Time Texture Synthesis with Markovian Generative Adversarial Networks. European Conference on Computer Vision. Springer, Cham, 2016 (https://arxiv.org/pdf/1604.04382.pdf).`
1. `Olaf Ronneberger, Philipp Fischer, and Thomas Brox. U-Net: Convolutional Networks for Biomedical Image Segmentation. International Conference on Medical image computing and computer-assisted intervention. Springer, Cham, 2015 (https://arxiv.org/pdf/1505.04597.pdf).`
1. `Judy Hoffman et al.: CyCADA: Cycle-Consistent Adversarial Domain Adaptation. arXiv preprint arXiv:1711.03213, 2017 (https://arxiv.org/pdf/1711.03213.pdf).`
\ No newline at end of file
......@@ -151,9 +151,7 @@
VAE 的结构类似于典型的自动编码器。 区别主要在于重新参数化技巧中的高斯随机变量的采样。 *清单 8.1.1* 显示了使用 MLP 实现的编码器,解码器和 VAE。
此代码也已添加到官方 Keras GitHub 存储库中:
[https://github.com/keras-team/keras/blob/master/examples/variational_autoencoder.py](https://github.com/keras-team/keras/blob/master/examples/variational_autoencoder.py )
[此代码也已添加到官方 Keras GitHub 存储库中](https://github.com/keras-team/keras/blob/master/examples/variational_autoencoder.py)
为便于显示潜在代码,将![](img/B14853_08_106.png)的维设置为 2。编码器仅是两层 MLP,第二层生成均值和对数方差。 对数方差的使用是为了简化 KL 损耗和重新参数化技巧的计算。 编码器的第三个输出是使用重新参数化技巧进行的![](img/B14853_08_107.png)采样。 我们应该注意,在采样函数![](img/B14853_08_108.png)中,因为![](img/B14853_08_109.png)假定它是高斯分布的标准偏差。
......@@ -167,7 +165,7 @@ VAE MLP 的 Keras 代码具有预训练的权重。 要测试,我们需要运
python3 vae-mlp-mnist-8.1.1.py --weights=vae_mlp_mnist.tf
```
完整的代码可以在以下链接中找到: [https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
[完整的代码可以在以下链接中找到](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
*清单 8.1.1*`vae-mlp-mnist-8.1.1.py`
......@@ -331,9 +329,7 @@ if __name__ == '__main__':
在原始论文*自动编码变化贝叶斯* [1]中,使用 MLP 来实现 VAE 网络,这与我们在上一节中介绍的类似。 在本节中,我们将证明使用 CNN 将显着提高所产生数字的质量,并将参数数量显着减少至 134,165。
*清单 8.1.3* 显示了编码器,解码器和 VAE 网络。 该代码也被添加到了官方的 Keras GitHub 存储库中:
[https://github.com/keras-team/keras/blob/master/examples/variational_autoencoder_deconv.py](https://github.com/keras-team/keras/blob/master/examples/variational_autoencoder_deconv.py )
*清单 8.1.3* 显示了编码器,解码器和 VAE 网络。 [该代码也被添加到了官方的 Keras GitHub 存储库中](https://github.com/keras-team/keras/blob/master/examples/variational_autoencoder_deconv.py)
为简洁起见,不再显示与 MLP VAE 类似的某些代码行。 编码器由两层 CNN 和两层 MLP 组成,以生成潜在代码。 编码器的输出结构与上一节中看到的 MLP 实现类似。 解码器由一层`Dense`和三层转置的 CNN 组成。
......@@ -670,7 +666,7 @@ CVAE 是![](img/B14853_08_127.png) -VAE 的特例,其中![](img/B14853_08_128.
图 8.3.2:MNIST 数字标签与测试数据集的潜矢量平均值的函数(![](img/B14853_08_140.png) -VAE 和![](img/B14853_08_141.png) 10)
原始图像可以在该书的 GitHub 存储库中找到,网址为 [https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras/tree/master/chapter8-vae](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras/tree/master/chapter8-vae)
[原始图像可以在该书的 GitHub 存储库中找到](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras/tree/master/chapter8-vae)
这些观察结果反映在*图 8.3.3* 中。 具有![](img/B14853_08_143.png) = *9 的![](img/B14853_08_127.png) -VAE* 具有两个实际上独立的潜在代码。 * z * [0]确定书写样式的倾斜度,而 *z* [1]指定数字的宽度和圆度(如果适用)。 对于![](img/B14853_08_145.png) = *10* 的![](img/B14853_08_144.png) -VAE, *z* [0]被静音。 * z * [0]的增加不会显着改变数字。 * z * [1]确定书写样式的倾斜角度和宽度:
......@@ -696,10 +692,10 @@ VAE 具有消除潜在向量纠缠的内在机制。 因此,构建![](img/B148
# 5.参考
1. Diederik P. Kingma 和 Max Welling。 *自动编码可变贝叶斯*。 arXiv 预印本 arXiv:1312.6114,2013( [https://arxiv.org/pdf/1312.6114.pdf](https://arxiv.org/pdf/1312.6114.pdf) )。
2. 孙基休,李洪立和严新辰。 *使用深度条件生成模型*学习结构化输出表示。 《神经信息处理系统进展》,2015 年( [http://papers.nips.cc/paper/5775-learning-structured-output-representation-using-deep-conditional-generative-models.pdf](http://papers.nips.cc/paper/5775-learning-structured-output-representation-using-deep-conditional-generative-models.pdf) )。
3. Yoshua Bengio,Aaron Courville 和 Pascal Vincent。 *表示学习*
4. *评论和新观点*。 IEEE 关于模式分析和机器智能的交易 35.8,2013:1798-1828( [https://arxiv.org/pdf/1206.5538.pdf](https://arxiv.org/pdf/1206.5538.pdf) )。
5. Xi Chen 等: *Infogan:通过信息最大化生成对抗网络*进行可解释的表示学习。 神经信息处理系统的进展,2016 年[ [http://papers.nips.cc/paper/6399-infogan-interpretable-representation-learning-in-information-maximizing-generative-adversarial-nets.pdf](http://papers.nips.cc/paper/6399-infogan-interpretable-representation-learning-by-information-maximizing-generative-adversarial-nets.pdf) )。
6. I.希金斯,L。Matthey,A。Pal,C。Burgess,X。Glorot,M。Botvinick,S。Mohamed 和 A. Lerchner。 ![](img/B14853_08_143.png) -VAE:*使用约束变分框架*学习基本的视觉概念。 ICLR,2017 年[ [https://openreview.net/pdf?id=Sy2fzU9gl](https://openreview.net/pdf?id=Sy2fzU9gl) )。
7. 卡尔·多尔施。 *可变自动编码器*教程。 arXiv 预印本 arXiv:1606.05908,2016( [https://arxiv.org/pdf/1606.05908.pdf](https://arxiv.org/pdf/1606.05908.pdf) )。
\ No newline at end of file
1. `Diederik P. Kingma and Max Welling. Auto-encoding Variational Bayes. arXiv preprint arXiv:1312.6114, 2013 (https://arxiv.org/pdf/1312.6114.pdf).`
1. `Kihyuk Sohn, Honglak Lee, and Xinchen Yan. Learning Structured Output Representation Using Deep Conditional Generative Models. Advances in Neural Information Processing Systems, 2015 (http://papers.nips.cc/paper/5775-learning-structured-output-representation-using-deep-conditional-generative-models.pdf).`
1. `Yoshua Bengio, Aaron Courville, and Pascal Vincent. Representation Learning.`
1. `A Review and New Perspectives. IEEE transactions on Pattern Analysis and Machine Intelligence 35.8, 2013: 1798-1828 (https://arxiv.org/pdf/1206.5538.pdf).`
1. `Xi Chen et al.: Infogan: Interpretable Representation Learning by Information Maximizing Generative Adversarial Nets. Advances in Neural Information Processing Systems, 2016 (http://papers.nips.cc/paper/6399-infogan-interpretable-representation-learning-by-information-maximizing-generative-adversarial-nets.pdf).`
1. `I. Higgins, L. Matthey, A. Pal, C. Burgess, X. Glorot, M. Botvinick, S. Mohamed, and A. Lerchner. -VAE: Learning Basic Visual Concepts with a Constrained Variational Framework. ICLR, 2017 (https://openreview.net/pdf?id=Sy2fzU9gl).`
1. `Carl Doersch. Tutorial on variational autoencoders. arXiv preprint arXiv:1606.05908, 2016 (https://arxiv.org/pdf/1606.05908.pdf).`
\ No newline at end of file
......@@ -170,7 +170,7 @@ sudo pip3 install termcolor
安装`termcolor`软件包。 该软件包有助于可视化终端上的文本输出。
完整的代码可以在 GitHub 上的 [https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras) 上找到
[完整的代码可以在 GitHub 上找到](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)
*清单 9.3.1*`q-learning-9.3.1.py`
......@@ -469,7 +469,7 @@ Q 学习是更广义的 TD 学习![](img/14853_09_044.png)的特例。 更具体
主要区别是使用已优化的策略来确定![](img/14853_09_049.png)。 必须知道术语![](img/14853_09_050.png),![](img/14853_09_051.png),![](img/14853_09_052.png),![](img/14853_09_053.png)和![](img/14853_09_054.png)(因此名称为 SARSA)才能在每次迭代时更新 Q 值函数。 Q 学习和 SARSA 都在 Q 值迭代中使用现有的估计,该过程称为*自举*。 在引导过程中,我们从奖励中更新当前的 Q 值估计,并随后更新 Q 值估计。
在提出另一个示例之前,似乎需要合适的 RL 模拟环境。 否则,我们只能对非常简单的问题(如上一个示例)运行 RL 模拟。 幸运的是,OpenAI 创建了 Gym [https://gym.openai.com](https://gym.openai.com) ,我们将在下一节中介绍。
在提出另一个示例之前,似乎需要合适的 RL 模拟环境。 否则,我们只能对非常简单的问题(如上一个示例)运行 RL 模拟。 幸运的是,OpenAI 创建了 [Gym](https://gym.openai.com),我们将在下一节中介绍。
## 在 OpenAI Gym 上进行 Q 学习
......@@ -1214,11 +1214,10 @@ DQN 提出了一种使用经验重播并将目标网络与受训 Q 网络分离
# 8.参考
1. Sutton 和 Barto:*强化学习:简介*,2017 年( [http://incompleteideas.net/book/bookdraft2017nov5.pdf](http://incompleteideas.net/book/bookdraft2017nov5.pdf) )。
2. Volodymyr Mnih 等人:*通过深度强化学习*进行人级控制。 自然 518.7540,2015:529( [http://www.davidqiu.com:8888/research/nature14236.pdf](http://www.davidqiu.com:8888/research/nature14236.pdf) )。
3. Hado Van Hasselt,Arthur Guez 和 David Silver:*带有双重 Q 学习的深度强化学习*。 AAAI。 卷 2016 年 6 月 16 日( [http://www.aaai.org/ocs/index.php/AAAI/AAAI16/paper/download/12389/11847](http://www.aaai.org/ocs/index.php/AAAI/AAAI16/paper/download/12389/11847) )。
4. Kai Arulkumaran 等:*深度强化学习*的简要概述。 arXiv 预印本 arXiv:1708.05866,2017( [https://arxiv.org/pdf/1708.05866.pdf](https://arxiv.org/pdf/1708.05866.pdf) )。
5. David Silver:*关于强化学习的讲义*[http://www0.cs.ucl.ac.uk/staff/d.silver/web/Teaching.html](http://www0.cs.ucl.ac.uk/staff/d.silver/web/Teaching.html) )。
6. Tom Schaul 等:*优先体验重播*。 arXiv 预印本 arXiv:1511.05952,2015( [https://arxiv.org/pdf/1511.05952.pdf](https://arxiv.org/pdf/1511.05952.pdf) )。
1. Wang Ziyu 等人:*深度强化学习的决斗网络架构*。 arXiv 预印本 arXiv:1511.06581,2015( [https://arxiv.org/pdf/1511.06581.pdf](https://arxiv.org/pdf/1511.06581.pdf) )。
\ No newline at end of file
1. `Sutton and Barto: Reinforcement Learning: An Introduction, 2017 (http://incompleteideas.net/book/bookdraft2017nov5.pdf).`
1. `Volodymyr Mnih et al.: Human-level Control through Deep Reinforcement Learning. Nature 518.7540, 2015: 529 (http://www.davidqiu.com:8888/research/nature14236.pdf).`
1. `Hado Van Hasselt, Arthur Guez, and David Silver: Deep Reinforcement Learning with Double Q-Learning. AAAI. Vol. 16, 2016 (http://www.aaai.org/ocs/index.php/AAAI/AAAI16/paper/download/12389/11847).`
1. `Kai Arulkumaran et al.: A Brief Survey of Deep Reinforcement Learning. arXiv preprint arXiv:1708.05866, 2017 (https://arxiv.org/pdf/1708.05866.pdf).`
1. `David Silver: Lecture Notes on Reinforcement Learning (http://www0.cs.ucl.ac.uk/staff/d.silver/web/Teaching.html).`
1. `Tom Schaul et al.: Prioritized experience replay. arXiv preprint arXiv:1511.05952, 2015 (https://arxiv.org/pdf/1511.05952.pdf).`
1. `Ziyu Wang et al.: Dueling Network Architectures for Deep Reinforcement Learning. arXiv preprint arXiv:1511.06581, 2015 (https://arxiv.org/pdf/1511.06581.pdf).`
\ No newline at end of file
......@@ -70,7 +70,7 @@
策略梯度定理在某种意义上是直观的,即性能梯度是根据目标策略样本估算的,并且与策略梯度成比例。 策略梯度由 Q 值缩放,以鼓励对状态值产生积极贡献的行动。 梯度还与动作概率成反比,以惩罚对提高性能没有贡献的频繁发生的动作。
有关策略梯度定理的证明,请参阅[2]和 David Silver 关于强化学习的讲义: [http://www0.cs.ucl.ac.uk/staff/d.silver/web/Teaching_files /pg.pdf](http://www0.cs.ucl.ac.uk/staff/d.silver/web/Teaching_files/pg.pdf)
有关策略梯度定理的证明,请参阅[2]和 [David Silver 关于强化学习的讲义](http://www0.cs.ucl.ac.uk/staff/d.silver/web/Teaching_files/pg.pdf)
与策略梯度方法相关的细微优势。 例如,在某些基于纸牌的游戏中,与基于策略的方法不同,基于价值的方法在处理随机性方面没有直接的过程。 在基于策略的方法中,操作概率随参数而平滑变化。
......@@ -572,11 +572,11 @@ class A2CAgent(PolicyAgent):
在本节中,我们将以一个代码讨论`tf.keras`算法 10.2.1 至*算法 10.5.1* 的通用例程在`tf.keras`中的实现。
完整的代码可以在 [https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras) 中找到。
完整的代码可以在[这个页面](https://github.com/PacktPublishing/Advanced-Deep-Learning-with-Keras)中找到。
但是在讨论实现之前,让我们简要探讨培训环境。
与 Q 学习不同,策略梯度方法适用于离散和连续动作空间。 在我们的示例中,我们将在连续动作空间案例示例中演示四种策略梯度方法,例如 OpenAI 健身房的`MountainCarContinuous-v0`[https://gym.openai.com](https://gym.openai.com) 。 如果您不熟悉 OpenAI Gym,请参阅*第 9 章**深度强化学习*
与 Q 学习不同,策略梯度方法适用于离散和连续动作空间。 在我们的示例中,我们将在连续动作空间案例示例中演示四种策略梯度方法,例如 OpenAI 健身房的[`MountainCarContinuous-v0`](https://gym.openai.com)。 如果您不熟悉 OpenAI Gym,请参阅*第 9 章**深度强化学习*
*中显示了`MountainCarContinuous-v0`二维环境的快照。图 10.6.1* 在此二维环境中,一辆功率不太强的汽车停在两座山之间:
......@@ -1147,13 +1147,13 @@ python3 policygradient-car-10.1.1.py
在本章中,我们介绍了策略梯度方法。 从策略梯度定理开始,我们制定了四种方法来训练策略网络。 详细讨论了四种方法:REINFORCE,带有基线的 REINFORCE,Actor-Critic 和 A2C 算法。 我们探讨了如何在 Keras 中实现这四种方法。 然后,我们通过检查代理成功达到目标的次数以及每集获得的总奖励来验证算法。
与上一章中讨论的深度 Q 网络[2]相似,基本策略梯度算法可以进行一些改进。 例如,最突出的一个是 A3C [3],它是 A2C 的多线程版本。 这使代理可以同时接触不同的经验,并异步优化策略和价值网络。 但是,在 OpenAI [https://blog.openai.com/baselines-acktr-a2c/](https://blog.openai.com/baselines-acktr-a2c/) 进行的实验中,与 A2C 相比,A3C 没有强大的优势,因为前者无法利用 A3C 的优势 当今提供强大的 GPU。
与上一章中讨论的深度 Q 网络[2]相似,基本策略梯度算法可以进行一些改进。 例如,最突出的一个是 A3C [3],它是 A2C 的多线程版本。 这使代理可以同时接触不同的经验,并异步优化策略和价值网络。 但是,在 [OpenAI](https://blog.openai.com/baselines-acktr-a2c/) 进行的实验中,与 A2C 相比,A3C 没有强大的优势,因为前者无法利用 A3C 的优势 当今提供强大的 GPU。
在接下来的两章中,我们将着手于另一个领域-对象检测和语义分割。 对象检测使代理能够识别和定位给定图像中的对象。 语义分割基于对象类别识别给定图像中的像素区域。
# 9.参考
1. 理查德·萨顿(Richard Sutton)和安德鲁·巴托(Andrew Barto):*强化学习:简介*[http://incompleteideas.net/book/bookdraft2017nov5.pdf](http://incompleteideas.net/book/bookdraft2017nov5.pdf) (2017 年)
2. Volodymyr Mnih 等人:*通过深度强化学习进行人级控制*,自然 518.7540(2015):529
3. Volodymyr Mnih 等人:*深度强化学习的异步方法*,国际机器学习会议,2016 年
4. Ronald Williams:*用于连接主义强化学习的简单统计梯度跟踪算法*,机器学习 8.3-4(1992):229-256
\ No newline at end of file
1. `Richard Sutton and Andrew Barto: Reinforcement Learning: An Introduction: http://incompleteideas.net/book/bookdraft2017nov5.pdf (2017)`
1. `Volodymyr Mnih et al.: Human-level control through deep reinforcement learning, Nature 518.7540 (2015): 529`
1. `Volodymyr Mnih et al.: Asynchronous Methods for Deep Reinforcement Learning, International conference on machine learning, 2016`
1. `Ronald Williams: Simple statistical gradient-following algorithms for connectionist reinforcement learning, Machine learning 8.3-4 (1992): 229-256`
\ No newline at end of file
......@@ -1297,9 +1297,7 @@ from skimage.io import imread
# 11\. SSD 模型训练
可以从以下链接下载包含 csv 格式标签的 train 和测试数据集:
[https://bit.ly/adl2-ssd](https://bit.ly/adl2-ssd)
[可以从以下链接下载包含 csv 格式标签的 train 和测试数据集](https://bit.ly/adl2-ssd)
在顶层文件夹(即*第 11 章**对象检测*)中,创建数据集文件夹,将下载的文件复制到此处,然后运行以下命令将其解压缩:
......@@ -1662,13 +1660,11 @@ python3 ssd-11.6.1.py --restore-weights=ResNet56v2-4layer-extra_anchors-drinks-2
# 15.参考
1. Krizhevsky Alex,Ilya Sutskever 和 Geoffrey E. Hinton。 “ *具有深度卷积神经网络*的 Imagenet 分类。” 神经信息处理系统的进步。 2012。
2. 刘伟,等。 “ *SSD:单发 MultiBox 检测器*。 欧洲计算机视觉会议。 占卜·斯普林格,2016
3. 吉希克·罗斯(Girshick Ross)。 “ *快速 R-CNN* 。 IEEE 计算机视觉国际会议论文集。 2015 年。
4. 林宗义等。 “ *密集物体检测的焦距损失*。” IEEE 国际计算机视觉会议论文集。 2017。
1. Dutta 等。 *VGG 图像注释器* [http://www.robots.ox.ac.uk/~vgg/software/via/](http://www.robots.ox.ac.uk/~vgg/software/via/)
1. Bodla Navaneeth 等。 “ *Soft-NMS-使用一行代码*改进对象检测。 IEEE 计算机视觉国际会议论文集。 2017。
2. Everingham Mark 等。 “ *Pascal 视觉对象类(VOC)挑战*。 国际计算机视觉杂志 88.2(2010):303-338。
3.*胡伯损耗*[https://zh.wikipedia.org/wiki/Huber_loss](https://en.wikipedia.org/wiki/Huber_loss)
\ No newline at end of file
1. `Krizhevsky Alex, Ilya Sutskever, and Geoffrey E. Hinton. "Imagenet classification with deep convolutional neural networks." Advances in neural information processing systems. 2012.`
1. `Liu Wei, et al. "SSD: Single Shot MultiBox Detector." European conference on computer vision. Springer, Cham, 2016.`
1. `Girshick Ross. "Fast R-CNN." Proceedings of the IEEE international conference on computer vision. 2015.`
1. `Lin Tsung-Yi, et al. "Focal loss for Dense Object Detection. "Proceedings of the IEEE international conference on computer vision. 2017.`
1. `Dutta, et al. VGG Image Annotator http://www.robots.ox.ac.uk/~vgg/software/via/`
1. `Bodla Navaneeth, et al. "Soft-NMS--Improving Object Detection With One Line of Code." Proceedings of the IEEE international conference on computer vision. 2017.`
1. `Everingham Mark, et al. "The Pascal Visual Object Classes (VOC) challenge." International journal of computer vision 88.2 (2010): 303-338.`
1. `"Huber Loss." https://en.wikipedia.org/wiki/Huber_loss`
\ No newline at end of file
......@@ -343,7 +343,7 @@ segmentation_train.json
segmentation_test.json
```
无法原样使用存储在 JSON 文件中的多边形区域。 每个区域都必须转换成分割蒙版,即张量,其尺寸为*图像* <sub style="font-style: italic;">宽度</sub> x *图像* <sub style="font-style: italic;">高度</sub> x *像素**wise_category* 。 在此数据集中,分割蒙版的尺寸为 640 x 480 x4。类别 0 为背景,其余为 1)对于**水瓶**,2)对于**苏打水 罐**,以及 3)表示**果汁罐**。 在`utils`文件夹中,我们创建了一个`generate_gt_segmentation.py`工具,用于将 JSON 文件转换为分段掩码。 为了方便起见,用于训练和测试的地面真实数据存储在压缩数据集中,该数据集是从上一章的 [https://bit.ly/adl2-ssd](https://bit.ly/adl2-ssd) 下载的:
无法原样使用存储在 JSON 文件中的多边形区域。 每个区域都必须转换成分割蒙版,即张量,其尺寸为*图像* <sub style="font-style: italic;">宽度</sub> x *图像* <sub style="font-style: italic;">高度</sub> x *像素**wise_category* 。 在此数据集中,分割蒙版的尺寸为 640 x 480 x4。类别 0 为背景,其余为 1)对于**水瓶**,2)对于**苏打水 罐**,以及 3)表示**果汁罐**。 在`utils`文件夹中,我们创建了一个`generate_gt_segmentation.py`工具,用于将 JSON 文件转换为分段掩码。 为了方便起见,用于训练和测试的地面真实数据存储在压缩数据集中,该数据集是从[上一章](https://bit.ly/adl2-ssd)下载的:
```py
segmentation_train.npy
......@@ -415,9 +415,8 @@ python3 fcn-12.3.1.py --evaluate
# 7.参考
1. Kirillov,Alexander 等:*全景分割*。 IEEE 关于计算机视觉和模式识别的会议论文集。 2019。
2. Long,Jonathan,Evan Shelhamer 和 Trevor Darrell:*用于语义分割的完全卷积网络*。 IEEE 关于计算机视觉和模式识别的会议论文集。 2015 年。
3. Zhao,Hengshuang 等:*金字塔场景解析网络*。 IEEE 关于计算机视觉和模式识别的会议论文集。 2017。
4. Dutta 等人: *VGG 图像注释器* [http://www.robots.ox.ac.uk/~vgg/software/via/](http://www.robots.ox.ac.uk/~vgg/software/via/)
1. 何开明等:*掩膜 R-CNN* 。 IEEE 计算机视觉国际会议论文集。 2017。
\ No newline at end of file
1. `Kirillov, Alexander, et al.: Panoptic Segmentation. Proceedings of the IEEE conference on computer vision and pattern recognition. 2019.`
1. L`ong, Jonathan, Evan Shelhamer, and Trevor Darrell: Fully Convolutional Networks for Semantic Segmentation. Proceedings of the IEEE conference on computer vision and pattern recognition. 2015.`
1. `Zhao, Hengshuang, et al.: Pyramid Scene Parsing Network. Proceedings of the IEEE conference on computer vision and pattern recognition. 2017.`
1. `Dutta, et al.: VGG Image Annotator http://www.robots.ox.ac.uk/~vgg/software/via/`
1. `He Kaiming, et al.: Mask R-CNN. Proceedings of the IEEE international conference on computer vision. 2017.`
\ No newline at end of file
......@@ -643,7 +643,7 @@ def unsupervised_labels(y, yp, n_classes, n_clusters):
使用此矩阵,群集类的分配显示在最右边的表中。 使用群集类分配时,第四行上只有一个错误。 结果精度为五分之四,即 80%。
我们可以将的线性分配问题扩展到为 10 个 MNIST 集群分配标签的问题。 我们在`scipy`包中使用`linear_sum_assignment()`功能。 该功能基于匈牙利算法。 *清单 13.5.6* 显示了群集标记过程的实现。 有关`linear_sum_assignment()`函数的更多详细信息,请参见 [https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.optimize.linear_sum_assignment.html](https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.optimize.linear_sum_assignment.html)
我们可以将的线性分配问题扩展到为 10 个 MNIST 集群分配标签的问题。 我们在`scipy`包中使用`linear_sum_assignment()`功能。 该功能基于匈牙利算法。 *清单 13.5.6* 显示了群集标记过程的实现。 有关`linear_sum_assignment()`函数的更多详细信息,请参见[这里](https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.optimize.linear_sum_assignment.html)
要训​​练 1 头情况下的 IIC 模型,请执行:
......@@ -1228,8 +1228,7 @@ python3 mine-13.8.1.py --train --batch-size=1024 --latent-dim=64 --epochs=200
# 11.参考
1. Ji,Xu,JoãoF.Henriques 和 Andrea Vedaldi。 *用于无监督图像分类和分割的不变信息聚类*。 国际计算机视觉会议,2019 年。
2. Simonyan,Karen 和 Andrew Zisserman。 *用于大型图像识别的非常深的卷积网络*。 arXiv 预印本 arXiv:1409.1556(2014)。
3. Belghazi,Mohamed Ishmael 等。 *互信息神经估计*。 机器学习国际会议。 2018。
1. [https://en.wikipedia.org/wiki/Mutual_information](https://en.wikipedia.org/wiki/Mutual_information)
\ No newline at end of file
1. `Ji, Xu, João F. Henriques, and Andrea Vedaldi. Invariant Information Clustering for Unsupervised Image Classification and Segmentation. International Conference on Computer Vision, 2019.`
1. `Simonyan, Karen, and Andrew Zisserman. Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556 (2014).`
1. `Belghazi, Mohamed Ishmael, et al. Mutual Information Neural Estimation. International Conference on Machine Learning. 2018.`
1. `https://en.wikipedia.org/wiki/Mutual_information.`
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册