资源简介
可以运行的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)
相关资源
- Tensorflow之CNN实现CIFAR-10图像的分类p
- Python人工智能AI深度学习全套课程.t
- 深度学习入门代码 5-1 mnist数据集.p
- 最详细神经网络python描写附注释
- 计算机视觉视频教程百度云盘资源
- tensorflow_random_forest_demo.py
- keras_inception_v4_finetune.py
- mnist_acgan.py
- 卷积神经网络轴承数故障分类
- 利用鸢尾花数据集画出P-R曲线 pytho
- python图像裁剪
- 目标检测自动标注代码
- 梯度下降python程序实现+可视化
- 基于深度学习的表情识别系统
- 语义分割标注转为目标检测框标注
- keras上LSTM长短期记忆网络金融时序预
- 深度学习 莫烦 Keras源代码
- 合并BN层的python脚本
- 机器学习深度学习篇系列分享_超值
- 《TensorFlow2深度学习》
- 深度学习视频教程,包括python入门,
- python三阶深度学习框架-Real-Time-Voice
-
xm
l_parse.py - 可直接运行版本python实现yolov3调用摄
- Deep Learning for Computer Vision with Python链
- 莫烦全部代码Reinforcement-learning-with-
- cifar-10-python.tar.gz的资源
- python全栈视频某智
- YOLO_train.py
- 强化深度学习迷宫问题
评论
共有 条评论