LSTM长短期记忆人工神经网络------实践
github有完整版的代码,这里只是有一点代码的讲解:
https://github.com/ICEJM1020/LSTM_Stock
3 使用keras LSTM实现股票预测
3.1配置Python环境和keras
配置python就不用多讲了,到官网上下载一个就行,现在的电脑基本都用64位的,个人不太喜欢conda版本的python,所以就不怎么用了。
第二个是keras,现在的tensorflow更新2.0版本以后呢就把keras给合并了,但是如果习惯用单独的keras的朋友也不用着急,keras的最后一次发行版本是支持了tensorflow2.0的:
- The current release is Keras 2.3.0, which makes significant API changes and add support for TensorFlow 2.0. The 2.3.0 release will be the last major release of multi-backend Keras. Multi-backend Keras is superseded by tf.keras.
使用keras之前需要先配置tensorflow,keras只是一个高级的API,底层还是需要tensorflow,我一般直接使用pip就能下载,但是有很多人都说pip下不了,大部分情况是网络问题,如果pip不行的话就使用阿里源或者清华源下载,用同样的方法也可以下载keras:
使用pip直接下载:
pip install tensorflow==2.0.0
(用2.1.0是最新版本,如果需要换掉就行)
pip install keras==2.3.0
tensorflow pip下载指南:https://tensorflow.google.cn/install/pip
使用清华源下载tensorflow:https://blog.csdn.net/jdbc/article/details/80969396
如果下载好了,进入python环境引用包就应该会有下图:
查看tensorflow的版本号:
打开cmd -》输入 python -》输入import tensorflow as tf -》 tf.__version__
查看keras的版本号:
打开cmd -》输入 python -》输入import keras -》 keras.__version__
如果喜欢的话可以下一个python的IDE,PyCharm我比较喜欢,如果不想用的,可以下载一个jupyter,使用pip下载:
pip install jupyter notebook
jupyter是一个网页的python编辑器,下载好了在cmd中输入:
jupyter notebook