资源简介
可以运行的LSTM实例,python代码实现,如有问题,可以随时联系我,希望可以和人工智能盆友多多交流,,,,,,,,,,,,,,,,,,,,,,,,,,,
代码片段和文件信息
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
# set random seed for comparing the two result calculations
tf.set_random_seed(1)
# this is data
mnist = input_data.read_data_sets(‘MNIST_data‘ one_hot=True)
# hyperparameters
lr = 0.001
training_iters = 100000
batch_size = 128
n_inputs = 28 # MNIST data input (img shape: 28*28)
n_steps = 28 # time steps
n_hidden_units = 128 # neurons in hidden layer
n_classes = 10 # MNIST classes (0-9 digits)
# tf Graph input
x = tf.placeholder(tf.float32 [None n_steps n_inputs])
y = tf.placeholder(tf.float32 [None n_classes])
# Define weights
weights = {
# (28 128)
‘in‘: tf.Variable(tf.random_normal([n_inputs n_hidden_units]))
# (128 10)
‘out‘: tf.Variable(tf.random_normal([n_hidden_units n_classes]))
}
biases = {
# (128 )
‘in‘: tf.Variable(tf.constant(0.1 shape=[n_hidden_units ]))
# (10 )
‘out‘: tf.Variable(tf.constant(0.1 shape=[n_classes ]))
}
def RNN(X weights biases):
# hidden layer for input to cell
########################################
# transpose the inputs shape from
# X ==> (128 batch * 28 steps 28 inputs)
X = tf.reshape(X [-1 n_inputs])
# into hidden
# X_in = (128 batch * 28 steps 128 hidden)
X_in = tf.matmul(X weights[‘in‘]) + biases[‘in‘]
# X_in ==> (128 batch 28 steps 128 hidden)
X_in = tf.reshape(X_in [-1 n_steps n_hidden_units])
# cell
##########################################
# basic LSTM Cell.
# if int((tf.__version__).split(‘.‘)[1]) < 12 and int((tf.__version__).split(‘.‘)[0]) < 1:
# lstm_cell = tf.nn.rnn_cell.BasicLSTMCell(n_hidden_units forget_bias=1.0 state_is_tuple=True)
# else:
# print(“22222“)
# lstm_cell = tf.contrib.rnn.BasicLSTMCell(n_hidden_units)
相关资源
- 7.图像风格迁移 基于深度学习 pyt
- dronet源码+论文(深度学习)
- 012345手势识别神经网络代码
- 深度学习(SPOT-RNA)
- 深度学习YOLOv3分类算法
- Deep Learning Cookbook_ practical recipes to g
- 深度学习视频中的行为识别
- deep learning with python 中文版
- 吴恩达深度学习超参数调制完整程序
- 深度学习入门 基于python理论与实现
- Python-基于深度学习的语音增强使用
- 《深度学习Deep Learning with Python 2017》
- 深度学习进阶:自然语言处理
- 基于深度学习堆栈自动编码器模型的
- 深度学习入门:基于python的理论与实
- 吴恩达深度学习1-21-31-42-1编程作业线
- 基于Python的深度学习
- 安全帽检测detect.7z
- deep_learning_with_python.pdf(Jason Brownlee)
- 人脸识别python代码187268
- Make Your Own Neural Network - 搭建自己的神
- BrownLee Better Deep Learning
- python 直方图规定化代码
- 简单粗暴 TensorFlow
- 5. 深度学习中的目标检测 python代码实
- 深度学习入门:基于Python的理论与实
- Deep Learning from Scratch中文名:深度学习
- Deep Learning for Natural Language Processing.
- 字符型图片数字验证码识别完整过程
- Python深度学习
评论
共有 条评论