运用tensorflow框架,用带有LSTM的RNN进行手写数字识别,手写数字的数据在这里点击打开链接
#!/usr/bin/env python # -*- coding:utf-8 -*- """ @author: Z.y @software: PyCharm @time: 2017/12/31 上午12:03 """ import os os.environ['TF_CPP_MIN_LOG_LEVEL']='2' from tensorflow.examples.tutorials.mnist import input_data from tensorflow.contrib import rnn import tensorflow as tf import numpy as np import matplotlib.pyplot as plt print ("Packages imported") mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) trainimgs, trainlabels, testimgs, testlabels \ = mnist.train.images, mnist.train.labels, mnist.test.images, mnist.test.labels ntrain, ntest, dim, nclasses \ = trainimgs.shape[0], testimgs.shape[