提交 8933e988 编写于 作者: W wizardforcel

2020-08-14 18:45:23

上级 e179f4c4
......@@ -954,9 +954,9 @@ An example of bitcoin value prediction
预测股市价值是一个不错的 RNN 应用程序,并且有许多方便的软件包,例如:
* Drnns-prediction 使用来自 Kaggle 的《股票市场每日新闻》数据集上的 Keras 神经网络库实现了深度 RNN。 数据集任务是使用当前和前一天的新闻头条作为特征来预测 DJIA 的未来走势。 开源代码可从 [https://github.com/jvpoulos/drnns-prediction](https://github.com/jvpoulos/drnns-prediction) 获得。
* 迈克尔·卢克(Michael Luk)撰写了一篇有趣的博客文章,内容涉及如何基于 RNN 预测可口可乐的库存量: [https://sflscientific.com/data-science-blog/2017/2/10/predicting-stock-volume-with- lstm](https://sflscientific.com/data-science-blog/2017/2/10/predicting-stock-volume-with-lstm)
* Jakob Aungiers 在 *LSTM 神经网络时间序列预测*:[上写了另一篇有趣的博客文章 http://www.jakob-aungiers.com/articles/a/LSTM-Neural -网络时间序列预测](http://www.jakob-aungiers.com/articles/a/LSTM-Neural-Network-for-Time-Series-Prediction)。
* Drnns-prediction 使用来自 Kaggle 的《股票市场每日新闻》数据集上的 Keras 神经网络库实现了深度 RNN。 数据集任务是使用当前和前一天的新闻头条作为特征来预测 DJIA 的未来走势。 开源代码可从[这里](https://github.com/jvpoulos/drnns-prediction)获得。
* 迈克尔·卢克(Michael Luk)撰写了一篇有趣的博客文章,[内容涉及如何基于 RNN 预测可口可乐的库存量](https://sflscientific.com/data-science-blog/2017/2/10/predicting-stock-volume-with-lstm)
* Jakob Aungiers 写了另一篇有趣的博客文章 [LSTM 神经网络时间序列预测](http://www.jakob-aungiers.com/articles/a/LSTM-Neural-Network-for-Time-Series-Prediction)。
# 多对一和多对多 RNN 示例
......
......@@ -251,7 +251,7 @@ fit(
这是我们进行食谱的方法:
1. 和以前一样,我们从加载必要的模块开始。 我们将像往常一样需要 TensorFlow,NumPy 和 Matplotlib。 在本食谱中,我们使用的是鸢尾花数据集,该数据集包含三个类别,每个类别有 50 个实例,其中每个类别都代表一种鸢尾花植物。 我们可以从 [https://archive.ics.uci.edu/ml/datasets/iris](https://archive.ics.uci.edu/ml/datasets/iris) 文件中下载数据作为`.csv`文件,也可以使用 sklearn 的数据集模块(scikit-learn) 做任务:
1. 和以前一样,我们从加载必要的模块开始。 我们将像往常一样需要 TensorFlow,NumPy 和 Matplotlib。 在本食谱中,我们使用的是鸢尾花数据集,该数据集包含三个类别,每个类别有 50 个实例,其中每个类别都代表一种鸢尾花植物。 我们可以从[这里](https://archive.ics.uci.edu/ml/datasets/iris)下载数据作为`.csv`文件,也可以使用 sklearn 的数据集模块(scikit-learn) 做任务:
```py
import numpy as np
......@@ -357,11 +357,11 @@ K 均值聚类非常流行,因为它快速,简单且健壮。 它还有一
* 奥尔特加,华金·佩雷斯(JoaquínPérez)等人。 *关于 k 均值算法的研究问题:使用 matlab* 的实验性试验。 CEUR 研讨会论文集:语义网和新技术。
* [http://home.deib.polimi.it/matteucc/Clustering/tutorial_html/kmeans.html](http://home.deib.polimi.it/matteucc/Clustering/tutorial_html/kmeans.html)
* <http://home.deib.polimi.it/matteucc/Clustering/tutorial_html/kmeans.html>
* 陈可 *关于度量和欧几里得空间中 k 均值和 k 均值聚类的核心集及其应用*。 SIAM 计算学报 39.3(2009):923-947。
* [https://zh.wikipedia.org/wiki/确定 _clusters_in_a_data_set 的编号](https://en.wikipedia.org/wiki/Determining_the_number_of_clusters_in_a_data_set)
* <https://en.wikipedia.org/wiki/Determining_the_number_of_clusters_in_a_data_set>
# 自组织图
......@@ -607,9 +607,9 @@ SOM 在计算上很昂贵,因此对于非常大的数据集并没有真正的
# 也可以看看
* 这是一篇非常不错的博客文章,用简单的语言解释了 SOM: [http://www.ai-junkie.com/ann/som/som1.html](http://www.ai-junkie.com/ann/som/som1.html)
* 关于 SOM 的简要介绍: [https://en.wikipedia.org/wiki/Self-organizing_map](https://en.wikipedia.org/wiki/Self-organizing_map)
* Kohonen 关于 SOM 的开创性论文:“自组织图”。 神经计算 21.1(1998):1-6: [https://pdfs.semanticscholar.org/8c6a/aea3159e9f49283de252d0548b337839ca6f.pdf](https://pdfs.semanticscholar.org/8c6a/aea3159e9f49283de252d0548b337839ca6f.pdf)
* [这是一篇非常不错的博客文章,用简单的语言解释了 SOM](http://www.ai-junkie.com/ann/som/som1.html)
* [关于 SOM 的简要介绍](https://en.wikipedia.org/wiki/Self-organizing_map)
* [Kohonen 关于 SOM 的开创性论文:“自组织图”。 神经计算 21.1(1998):1-6](https://pdfs.semanticscholar.org/8c6a/aea3159e9f49283de252d0548b337839ca6f.pdf)
# 受限玻尔兹曼机
......@@ -794,7 +794,7 @@ for fig, row in zip([Xtest_noisy,out], axarr):
* 欣顿,杰弗里。 *训练受限 Boltzmann 机器*的实用指南。 Momentum 9.1(2010):926.([链接](http://www.csri.utoronto.ca/~hinton/absps/guideTR.pdf)
* 如果您对数学感兴趣,这是一个很好的教程: [http://deeplearning.net/tutorial/rbm.html#rbm](http://deeplearning.net/tutorial/rbm.html#rbm)
* 如果您对数学感兴趣,[这是一个很好的教程](http://deeplearning.net/tutorial/rbm.html#rbm)
# 使用 RBM 的推荐系统
......@@ -802,7 +802,7 @@ for fig, row in zip([Xtest_noisy,out], axarr):
# 做好准备
为了使用协作过滤创建推荐系统,我们需要修改数据。 作为说明,我们将使用来自 [https://grouplens.org/datasets/movielens/](https://grouplens.org/datasets/movielens/) 的电影数据集。 数据由两个`.dat`文件组成:`movies.dat``ratings.dat``movies.dat`文件包含 3 列:3883 个电影的 MovieID,Title 和 Genre。 `ratings.dat`文件包含四列:UserID,MovieID,Rating 和 Time。 我们需要合并这两个数据文件,以便能够构建一个数组,其中对于每个用户,我们对所有 3,883 部电影都有一个评分。 问题在于用户通常不会对所有电影进行评级,因此我们仅对某些电影进行非零(标准化)评级。 其余部分设为零,因此不会对隐藏层有所贡献。
为了使用协作过滤创建推荐系统,我们需要修改数据。 作为说明,我们将使用来自[这里](https://grouplens.org/datasets/movielens/)的电影数据集。 数据由两个`.dat`文件组成:`movies.dat``ratings.dat``movies.dat`文件包含 3 列:3883 个电影的 MovieID,Title 和 Genre。 `ratings.dat`文件包含四列:UserID,MovieID,Rating 和 Time。 我们需要合并这两个数据文件,以便能够构建一个数组,其中对于每个用户,我们对所有 3,883 部电影都有一个评分。 问题在于用户通常不会对所有电影进行评级,因此我们仅对某些电影进行非零(标准化)评级。 其余部分设为零,因此不会对隐藏层有所贡献。
# 怎么做...
......@@ -847,7 +847,7 @@ with tf.Session() as sess:
# 还有更多...
杰弗里·欣顿(Geoffrey Hinton)教授领导的多伦多大学团队赢得了 Netflix 最佳协作过滤竞赛的冠军,该协作过滤使用 RBM [(https://en.wikipedia.org/wiki/Netflix_Prize)](https://en.wikipedia.org/wiki/Netflix_Prize)来预测电影的用户收视率。 可以从他们的论文中获取其工作的详细信息: [http://www.cs.toronto.edu/~hinton/absps/netflixICML.pdf](http://www.cs.toronto.edu/~hinton/absps/netflixICML.pdf)
杰弗里·欣顿(Geoffrey Hinton)教授领导的多伦多大学团队赢得了 Netflix 最佳协作过滤竞赛的冠军,该协作过滤使用 [RBM](https://en.wikipedia.org/wiki/Netflix_Prize) 来预测电影的用户收视率。 [可以从他们的论文中获取其工作的详细信息](http://www.cs.toronto.edu/~hinton/absps/netflixICML.pdf)
一个 RBM 的隐藏单元的输出可以馈送到另一个 RBM 的可见单元,可以重复此过程以形成 RBM 的堆栈。 这导致**堆叠的 RBM** 。 假定不存在其他堆叠式 RBM,则对其进行独立训练。 大量堆叠的 RBM 构成了**深度信任网络(DBN)**。 可以使用有监督或无监督的训练来训练 DBN。 您将在下一个食谱中了解有关它们的更多信息。
......@@ -865,7 +865,7 @@ def rbm_output(self,X):
return self.session.run(x, feed_dict={self._X: X})
```
对于数据,我们考虑了 Kaggle 面部表情识别数据,该数据可从 [https://www.kaggle.com/c/challenges-in-representation-learning-facial-expression-recognition-challenge](https://www.kaggle.com/c/challenges-in-representation-learning-facial-expression-recognition-challenge) 获得。 此处给出的数据描述为:
对于数据,我们考虑了 Kaggle 面部表情识别数据,该数据可从[这里](https://www.kaggle.com/c/challenges-in-representation-learning-facial-expression-recognition-challenge)获得。 此处给出的数据描述为:
The data consists of 48 x 48 pixel grayscale images of faces. The faces have been automatically registered so that the face is more or less centered and occupies about the same amount of space in each image. The task is to categorize each face based on the emotion shown in the facial expression into one of seven categories (0=Angry, 1=Disgust, 2=Fear, 3=Happy, 4=Sad, 5=Surprise, 6=Neutral).
train.csv contains two columns, "emotion" and "pixels". The "emotion" column contains a numeric code ranging from 0 to 6, inclusive, for the emotion that is present in the image. The "pixels" column contains a string surrounded in quotes for each image. The contents of this string are space-separated pixel values in row major order. test.csv contains only the "pixels" column and your task is to predict the emotion column.
......@@ -905,7 +905,7 @@ def preprocess_data(dataframe):
return images, labels
```
使用前面代码中定义的函数,我们以训练所需的格式获取数据。 基于本文针对 MNIST 提到的相似原理,我们构建了情感检测 DBN: [https://www.cs.toronto.edu/~hinton/absps/fastnc.pdf](https://www.cs.toronto.edu/~hinton/absps/fastnc.pdf)
使用前面代码中定义的函数,我们以训练所需的格式获取数据。 基于本文针对 MNIST 提到的相似原理,我们构建了[情感检测 DBN](https://www.cs.toronto.edu/~hinton/absps/fastnc.pdf)
# 怎么做...
......@@ -1126,7 +1126,7 @@ with tf.Session() as sess:
RBM 使用无监督学习来学习模型的隐藏表示/功能,然后对与预训练 RBM 一起添加的全连接层进行微调。
这里的精度在很大程度上取决于图像表示。 在前面的食谱中,我们没有使用图像处理,仅使用了 0 到 1 之间缩放的灰度图像。但是,如果我们按照以下论文所述添加图像处理,则会进一步提高精度- [http:// deeplearning。 净/wp-content/uploads/2013/03/dlsvm.pdf](http://deeplearning.net/wp-content/uploads/2013/03/dlsvm.pdf) 。 因此,我们在`preprocess_data`函数中将每个图像乘以 100.0 / 255.0,然后将以下几行代码添加到主代码中:
这里的精度在很大程度上取决于图像表示。 在前面的食谱中,我们没有使用图像处理,仅使用了 0 到 1 之间缩放的灰度图像。但是,如果我们按照以下论文所述添加图像处理,[则会进一步提高精度](http://deeplearning.net/wp-content/uploads/2013/03/dlsvm.pdf)。 因此,我们在`preprocess_data`函数中将每个图像乘以 100.0 / 255.0,然后将以下几行代码添加到主代码中:
```py
std_image = np.std(X_train, axis=0)
......@@ -1139,8 +1139,8 @@ X_test = np.divide(np.subtract(X_test,mean_image), std_image)
在前面的示例中,没有进行预处理,这三个数据集的准确性大约为 40%。 但是,当我们添加预处理时,训练数据的准确性将提高到 90%,但是对于验证和测试,我们仍然可以获得约 45%的准确性。
可以引入许多更改来改善结果。 首先,我们在配方中使用的数据集是只有 22,000 张图像的 Kaggle 数据集。 如果观察这些图像,则会发现仅过滤面部的步骤会改善结果。 如下文所述,另一种策略是增加隐藏层的大小而不是减小它们的大小- [https://www.cs.swarthmore.edu/~meeden/cs81/s14/papers/KevinVincent.pdf [](https://www.cs.swarthmore.edu/~meeden/cs81/s14/papers/KevinVincent.pdf)
可以引入许多更改来改善结果。 首先,我们在配方中使用的数据集是只有 22,000 张图像的 Kaggle 数据集。 如果观察这些图像,则会发现仅过滤面部的步骤会改善结果。 如下文所述,[另一种策略是增加隐藏层的大小而不是减小它们的大小](https://www.cs.swarthmore.edu/~meeden/cs81/s14/papers/KevinVincent.pdf)
在识别情绪方面确实非常成功的另一个更改是使用面部关键点而不是整个面部训练, [http://cs229.stanford.edu/proj2010/McLaughlinLeBayanbat-RecognizingEmotionsWithDeepBeliefNets.pdf](http://cs229.stanford.edu/proj2010/McLaughlinLeBayanbat-RecognizingEmotionsWithDeepBeliefNets.pdf)
在识别情绪方面确实非常成功的另一个更改是[使用面部关键点而不是整个面部训练](http://cs229.stanford.edu/proj2010/McLaughlinLeBayanbat-RecognizingEmotionsWithDeepBeliefNets.pdf)
使用前面的配方,您可以尝试这些更改并探索性能如何提高。 愿 GPU 力量与您同在!
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册