Tensorflow股票预测循环神经网络

        GRU 由 Cho 等人于 2014 年提出,优化 LSTM 结构。Kyunghyun Cho,Bart van Merrienboer,Caglar Gulcehre,Dzmitry Bahdanau,Fethi Bougares,Holger Schwenk,Yoshua Bengio.Learning Phrase Representations using RNN Encoder–Decoder for Statistical Machine Translation.Computer ence, 2014.

        原理: 门控循环单元(Gated Recurrent Unit,GRU)是 LSTM 的一种变体,将 LSTM 中 遗忘门与输入门合二为一为更新门,模型比 LSTM 模型更简单。

        Tensorflow描述 GRU 层 tf.keras.layers.GRU(神经元个数, return_sequences=是否返回输出) 神经元个数和 return_sequences 的含义与 SimpleRNN 相同。 例:GRU(8,return_sequences=True)

        GRU 股票预测代码如下

import numpy as np
import tensorflow as tf
from tensorflow.keras.layers import Dropout, Dense, GRU
import matplotlib.pyplot as plt
import os
import pandas as pd
from sklearn.preprocessing import MinMaxScaler
from sklearn.metrics import mean_squared_error, mean_absolute_error
import math

maotai = pd.read_csv('D:/tensorflow/class6/SH600519.csv') 

你可能感兴趣的:(机器学习,tensorflow,深度学习)