“微信公众号”

一、回归预测要实现的问题
这次我们会使用RNN来进行回归(Regression)的训练,使用自己创建的sin曲线预测一条cos曲线。如下图所示,我们用蓝色的sin曲线预测红色的cos曲线。

二、回归预测要实现的效果
经过RNN的回归训练,我们的网络预测结果和真实结果的一个比对图,如下所示。

三、网络结构展示

四、代码展示
#conding:utf-8
'''
Please note, this code is only for python 3+. If you are using python 2+, please modify the code accordingly.
Run this script on tensorflow r0.10. Errors appear when using lower versions.
'''
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
# define super-parameters
BATCH_START = 0 # 建立batch data时候的index
TIME_STEPS = 20 # backpropagation through time 的 time_steps
BATCH_SIZE = 50
INPUT_SIZE = 1 # sin 数据输入size
OUTPUT_SIZE = 1 # cos数据输出size
CELL_SIZE = 10 # RNN的hidden unit size
LR
使用Tensorflow的LSTM进行回归预测

本文通过Tensorflow利用LSTM模型进行回归预测,具体应用是在已知sin曲线数据的情况下,训练模型预测cos曲线。文章介绍了问题背景、预期效果,并展示了网络结构和详细代码。
最低0.47元/天 解锁文章
6165

被折叠的 条评论
为什么被折叠?



