mnist

MNIST手写体识别入门程序整理

会有一股神秘感。 提交于 2019-11-26 04:00:00
MNIST手写体识别入门程序整理 我自己觉得Tensorflow中文官网是个学习的好地方,mnist新手入门有详细的教程,可以把链接分享给大家。 http://www.tensorfly.cn/tfdoc/tutorials/mnist_beginners.html 由于教程里面程序是散的,鉴于有一些懒虫程序员不想自己敲代码,所以我把代码整理了一下,只要将下面的代码复制粘特到python编辑器里,直接运行就可以自动下载数据包,并将结果给出。 import tensorflow.examples.tutorials.mnist.input_data as input_data mnist = input_data.read_data_sets(“MNIST_data/”, one_hot=True) import tensorflow as tf x = tf.placeholder(“float”, [None, 784]) W = tf.Variable(tf.zeros([784,10])) b = tf.Variable(tf.zeros([10])) y = tf.nn.softmax(tf.matmul(x,W) + b) y_ = tf.placeholder(“float”, [None,10]) cross_entropy = -tf.reduce_sum(y_

用keras实验mnist数据

会有一股神秘感。 提交于 2019-11-26 03:59:36
# -*- coding: utf-8 -*- """ Created on Mon Oct 30 19:44:02 2017 @author: user """ from __future__ import print_function # 导入numpy库, numpy是一个常用的科学计算库,优化矩阵的运算 import numpy as np np.random.seed( 1337 ) # 导入mnist数据库, mnist是常用的手写数字库 # 导入顺序模型 from keras.models import Sequential # 导入全连接层Dense, 激活层Activation 以及 Dropout层 from keras.layers.core import Dense, Dropout, Activation # 设置batch的大小 batch_size = 100 # 设置类别的个数 nb_classes = 10 # 设置迭代的次数 nb_epoch = 20 ''' 下面这一段是加载mnist数据,网上用keras加载mnist数据都是用 (X_train, y_train), (X_test, y_test) = mnist.load_data() 但是我用这条语句老是出错:OSError: [Errno 22] Invalid argument '

TensorFlow运行MNIST样例碰到下载数据的问题

拜拜、爱过 提交于 2019-11-26 03:58:02
Tensorflow安装完成之后,首先使用Softmax实现MNIST。 首先运行以下代码下载MNIST数据集。 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) 提示错误:IOError: [Errno socket error] [Errno 8] _ssl.c:510: EOF occurred in violation of protocol,无法下载数据集。 错误截图: Socket报错,初步判断是网络协议问题导致下载失败。google一圈没找到解决办法。最后只能手动去下载MINIST数据集, MNIST数据集下载 ,然后在当前目录下新建MNIST_data文件夹,将四个文件放入,然后执行Softmax代码,问题解决,最后结果为0.9115。 Softmax代码: # encoding: utf-8 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets(

SGD与Adam识别MNIST数据集

元气小坏坏 提交于 2019-11-25 22:05:41
几种常见的优化函数比较: https://blog.csdn.net/w113691/article/details/82631097 1 ''' 2 基于Adam识别MNIST数据集 3 ''' 4 import torch 5 import torchvision 6 import torchvision.transforms as transform 7 import torch.nn 8 from torch.autograd import Variable 9 10 ''' 11 神经网络层级结构: 12 卷积层Conv1,Conv2() 13 最大池化层 MaxPool2d() 14 损失函数 ReLU() 15 参数: 16 卷积神经网络的卷积层参数:------输入通道数、输出通道数、卷积核大小、卷积核移动步长和Padding的值 17 Conv2d(input_channels,output_channels,kernel_size,stride,padding); 18 最大池化层参数:------池化窗口大小、移动步长 19 MaxPool2d(kernel_size,stride) 20 方法: 21 1.torch.nn.Sequential()用作参数序列化,神经网络模块会按照传入Suquential构造器顺序依次被添加到计算图中执行 22 2