mnist

自编码实例1: MNIST

匿名 (未验证) 提交于 2019-12-02 23:34:01
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/QFire/article/details/90437796 import tensorflow as tf import numpy as np import matplotlib.pyplot as plt # 导入 MINST 数据集 from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("/data/", one_hot=True) # 网络模型参数 learning_rate = 0.01 n_hidden_1 = 256 # 第一层256 n_hidden_2 = 128 # 第二层128 n_input = 784 x = tf.placeholder("float", [None, n_input]) y = x # 参数 weights = { "encoder_h1": tf.Variable(tf.random_normal([n_input, n_hidden_1])), "encoder_h2": tf.Variable(tf.random_normal([n_hidden_1, n_hidden_2])), "decoder

ubuntu安装caffe

匿名 (未验证) 提交于 2019-12-02 23:34:01
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler -y sudo apt-get install --no-install-recommends libboost-all-dev -y sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev -y sudo apt-get install python-dev -y 下载caffe源码 git clone https://github.com/BVLC/caffe.git 修改编译配置文件: cd caffe 复制示例文件为编译配置文件: nano Makefile.config GPU版:将#USE_CUDNN := 1 修改成: USE_CUDNN := 1 将# Whatever else you find you need goes here.下面的 INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib 修改为:

MNIST机器学习入门(一)

匿名 (未验证) 提交于 2019-12-02 23:32:01
一、简介    首先介绍MNIST 数据集。如图1-1 所示, MNIST 数据集主要由一些手写数字的图片和相应的标签组成,图片一共有10 类,分别对应从0~9 ,共10 个阿拉伯数字。      原始的MNIST 数据库一共包含下面4 个文件, 见表1-1 。       在表1 - 1 中,图像数据是指很多张手写字符的图像,图像的标签是指每一张图像实际对应的数字是几,也就是说,在MNIST 数据集中的每一张图像都事先标明了对应的数字。 在MNIST 数据集中有两类图像:一类是训练图像(对应文件train-images-idx3-ubyte.gz 和train - labels-idx1-ubyte.gz ), 另一类是测试图像(对应文件t10k-images-idx3-ubyte.gz 和t10k-labels-idx1-ubyte.gz ) 。训练图像一共有60000 张,供研究人员训练出合适的模型。测试图像一共有10000 张,供研究人员测试训练的模型的性能。在TensorFlow 中, 可以使用下面的Python 代码下载MNIST 数据(在随书附赠的代码中,该代码对应的文件是donwload.py )。 # 从tensorflow.examples.tutorials.mnist引入模块。这是TensorFlow为了教学MNIST而提前编制的程序 from

数字识别,神经网络

元气小坏坏 提交于 2019-12-02 23:29:07
来源:https://www.numpy.org.cn/deep/basics/fit_a_line.html 数字识别 本教程源代码目录在 book/recognize_digits ,初次使用请您参考 Book文档使用说明 。 # 说明: 硬件环境要求: 本文可支持在CPU、GPU下运行 Docker镜像支持的CUDA/cuDNN版本: 如果使用了Docker运行Book,请注意:这里所提供的默认镜像的GPU环境为 CUDA 8/cuDNN 5,对于NVIDIA Tesla V100等要求CUDA 9的 GPU,使用该镜像可能会运行失败。 文档和脚本中代码的一致性问题: 请注意:为使本文更加易读易用,我们拆分、调整了train.py的代码并放入本文。本文中代码与train.py的运行结果一致,可直接运行 train.py 进行验证。 # 背景介绍 当我们学习编程的时候,编写的第一个程序一般是实现打印"Hello World"。而机器学习(或深度学习)的入门教程,一般都是 MNIST 数据库上的手写识别问题。原因是手写识别属于典型的图像分类问题,比较简单,同时MNIST数据集也很完备。MNIST数据集作为一个简单的计算机视觉数据集,包含一系列如图1所示的手写数字图片和对应的标签。图片是28x28的像素矩阵,标签则对应着0~9的10个数字。每张图片都经过了大小归一化和居中处理。

python: MNIST的图像显示

匿名 (未验证) 提交于 2019-12-02 22:51:30
1 import sys , os 2 sys . path . append ( os . pardir ) 3 import numpy as np 4 from dataset . mnist import load_mnist 5 from PIL import Image 6 7 def img_show ( img ): 8 pil_img = Image . fromarray ( np . uint8 ( img )) 9 pil_img . show () 10 11 ( x_train , t_train ), ( x_test , t_test ) = load_mnist ( flatten = True , 12 normalize = False ) 13 img = x_train [ 0 ] 14 label = t_train [ 0 ] 15 print ( label ) # 5 16 17 print ( img . shape ) # (784,) 18 img = img . reshape ( 28 , 28 ) # 把图像的形状变成原来的尺寸 19 print ( img . shape ) # (28, 28) 20 21 img_show ( img ) 显示mnist图像,执行上述代码后,训练图像的第一张会显示出来。 sys

How to put my dataset in a .pkl file in the exact format and data structure used in “mnist.pkl.gz”?

泄露秘密 提交于 2019-12-02 21:07:28
I'm trying to use the Theano library in python to do some experiments with Deep Belief Networks. I use the code in this address: DBN full code . This code use the MNIST Handwritten database . This file is already in pickle format. It is unpicked in: train_set valid_set test_set Which is further unpickled in: train_set_x, train_set_y = train_set valid_set_x, valid_set_y = valid_set test_set_x, test_set_y = test_set Please can someone give me the code that constructs this dataset in order to create my own? The DBN example I use needs the data in this format and I don't know how to do it. if

Extract images from .idx3-ubyte file or GZIP via Python

末鹿安然 提交于 2019-12-02 19:17:50
I have created a simple function for facerecognition by using the facerecognizer from OpenCV. It works all fine with images from people. Now I would like to make a test by using handwritten characters instead of people. I came across MNIST dataset, but they store images in a weird file which I have never seen before. I simply need to extract a few images from: train-images.idx3-ubyte and save them in a folder as .gif Or am I missunderstand this MNIST thing. If yes where could I get such a dataset? EDIT I also have the gzip file: train-images-idx3-ubyte.gz I am trying to read the content, but

How to unpack pkl file?

别说谁变了你拦得住时间么 提交于 2019-12-02 14:21:25
I have a pkl file from MNIST dataset, which consists of handwritten digit images. I'd like to take a look at each of those digit images, so I need to unpack the pkl file, except I can't find out how. Is there a way to unpack/unzip pkl file? Generally Your pkl file is, in fact, a serialized pickle file, which means it has been dumped using Python's pickle module. To un-pickle the data you can: import pickle with open('serialized.pkl', 'rb') as f: data = pickle.load(f) For the MNIST data set Note gzip is only needed if the file is compressed: import gzip import pickle with gzip.open('mnist.pkl

Unexpected increase in validation error in MNIST Pytorch

杀马特。学长 韩版系。学妹 提交于 2019-12-02 12:51:42
问题 I'm a bit new to the whole field and thus decided to work on the MNIST dataset. I pretty much adapted the whole code from https://github.com/pytorch/examples/blob/master/mnist/main.py, with only one significant change: Data Loading. I didn't want to use the pre-loaded dataset within Torchvision. So I used MNIST in CSV. I loaded the data from CSV file by inheriting from Dataset and making a new dataloader. Here's the relevant code: mean = 33.318421449829934 sd = 78.56749081851163 # mean = 0

PRML-master运行notebook报错问题

左心房为你撑大大i 提交于 2019-12-02 12:26:03
解决贝叶斯网络的ipynb文件运行问题 问题描述 使用fetch_mldata函数一直下载不下来数据集 from sklearn.datasets import fetch_mldata mnist = fetch_mldata('MNIST original') 使用时报错问题 D:\CodeSoftware\anaconda\lib\site-packages\sklearn\utils\deprecation.py:85: DeprecationWarning: Function fetch_mldata is deprecated; fetch_mldata was deprecated in version 0.20 and will be removed in version 0.22. Please use fetch_openml. warnings.warn(msg, category=DeprecationWarning) D:\CodeSoftware\anaconda\lib\site-packages\sklearn\utils\deprecation.py:85: DeprecationWarning: Function mldata_filename is deprecated; mldata_filename was deprecated in