基于Tensorflow的MNIST手写数字识别分类

本文介绍如何使用Tensorflow框架进行MNIST手写数字数据集的分类任务,通过示例代码详细展示了模型训练过程。
摘要由CSDN通过智能技术生成
  • 代码如下:
import tensorflow as tf
import numpy as np
from tensorflow.examples.tutorials.mnist import input_data
from tensorflow.contrib.tensorboard.plugins import projector
import time

IMAGE_PIXELS = 28
hidden_unit = 100
output_nums = 10
learning_rate = 0.001
train_steps = 50000
batch_size = 500
test_data_size = 10000
#日志目录(这里根据自己的目录修改)
logdir = 'D:/Develop_Software/Anaconda3/WorkDirectory/summary/mnist'
#导入mnist数据
mnist = input_data.read_data_sets('MNIST_data', one_hot = True)

  #全局训练步数
global_step = tf.Variable(0, name = 'global_step', trainable = False)
with tf.name_scope('input'):
  #输入数据
  with tf.name_scope('x'):
    x = tf.placeholder(
        dtype = tf.float32, shape = (None, IMAGE_PIXELS * IMAGE_PIXELS))
  #收集x图像的会总数据
  with tf.name_scope('x_summary'):
    shaped_image_batch = tf.reshape(
        tensor = x,
        shape = (-1, IMAGE_PIXELS, IMAGE_PIXELS, 1),
        name = 'shaped_image_batch')
    tf.summary.image(name = 'image_summary',
                     tensor = shaped_image_batch,
                     max_outputs = 10)
  with tf.name_scope('y_'):
    y_ = tf.placeholder(dtype = tf.float32, shape = (None
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值