mnist

Tensorflow Deep MNIST: Resource exhausted: OOM when allocating tensor with shape[10000,32,28,28]

与世无争的帅哥 提交于 2019-12-29 03:21:26
问题 This is the sample MNIST code I am running: from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data', one_hot=True) import tensorflow as tf sess = tf.InteractiveSession() x = tf.placeholder(tf.float32, shape=[None, 784]) y_ = tf.placeholder(tf.float32, shape=[None, 10]) W = tf.Variable(tf.zeros([784,10])) b = tf.Variable(tf.zeros([10])) y = tf.nn.softmax(tf.matmul(x,W) + b) def weight_variable(shape): initial = tf.truncated_normal(shape, stddev

TensorFlow:经典数据集加载

不羁的心 提交于 2019-12-28 15:59:35
在 TensorFlow 中, keras.datasets 模块提供了常用经典数据集的自动下载、管理、加载与转换功能,并且提供了 tf.data.Dataset 数据集对象,方便实现多线程(Multi-thread),预处理(Preprocess),随机打散(Shuffle)和批训练(Train on batch)等常用数据集功能。 常用的数据集: (1)Boston Housing 波士顿房价趋势数据集,用于回归模型训练与测试 (2)CIFAR10/100 真实图片数据集,用于图片分类任务 (3)MNIST/Fashion_MNIST 手写数字图片数据集,用于图片分类任务 (4)IMDB 情感分类任务数据集 这些数据集在机器学习、深度学习的研究和学习中使用的非常频繁。对于新提出的算法, 一般优先在简单的数据集上面测试,再尝试迁移到更大规模、更复杂的数据集上。 通过 datasets.xxx.load_data() 即可实现经典数据集的自动加载,其中xxx 代表具体的数据集名称。 TensorFlow 会默认将数据缓存在用户目录下的.keras/datasets 文件夹,如图 所示,用户不需要关心数据集是如何保存的。如果当前数据集不在缓存中,则会自动从网 站下载和解压,加载;如果已经在缓存中,自动完成加载: import tensorflow as tf from

【深度残差收缩网络】计算机视觉的应用代码

大兔子大兔子 提交于 2019-12-28 13:00:15
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 深度残差收缩网络是一种新的神经网络结构,实际上是深度残差网络的升级版本,能够在一定程度上提高深度学习方法在含噪数据上的特征学习效果。 首先,简要回顾一下深度残差网络,其基本模块如下图所示。相较于传统的卷积神经网络,深度残差网络利用了跨越多层的恒等映射,来缓解模型训练的难度,提高准确性。 然后,和深度残差网络不同的是,深度残差收缩网络引入了一个小型的子网络,用这个子网络学习得到一组阈值,对特征图的各个通道进行软阈值化。 这个过程其实可以看成一个可训练的特征选择的过程 。具体而言,就是通过前面的卷积层将重要的特征转换成绝对值较大的值,将冗余信息所对应的特征转换成绝对值较小的值;通过子网络学习得到二者之间的界限,并且通过软阈值化将冗余特征置为零,同时使重要的特征有着非零的输出。 深度残差收缩网络其实是一种通用的方法,不仅可以用于含噪数据,也可以用于不含噪声的情况。 这是因为,深度残差收缩网络中的阈值是根据样本情况自适应确定的。换言之,如果样本中不含冗余信息、不需要软阈值化,那么阈值可以被训练得非常接近于零,从而软阈值化就相当于不存在了。 最后,堆叠一定数量的基本模块,就得到了完整的网络结构。 利用深度残差收缩网络进行MNIST数据集的分类,可以看到,效果还是不错的。下面是深度残差收缩网络的代码: #!/usr/bin

Caffe的hello world

别说谁变了你拦得住时间么 提交于 2019-12-28 05:31:10
最终训练结果图 参照https://blog.csdn.net/liuweiyuxiang/article/details/79532073 修改的两条命令也就是批处理文件 转换数据的mnist_data.dat .\build\examples\mnist\Release\convert_mnist_data.exe .\data\mnist\train-images.idx3-ubyte .\data\mnist\train-labels.idx1-ubyte .\examples\mnist\mnist_train_lmdb echo. .\build\examples\mnist\Release\convert_mnist_data.exe .\data\mnist\t10k-images.idx3-ubyte .\data\mnist\t10k-labels.idx1-ubyte .\examples\mnist\mnist_test_lmdb pause 训练的train_minist.dat .\build\tools\Release\caffe.exe train --solver=.\examples\mnist\lenet_solver.prototxt pause 来源: CSDN 作者: 八倍体小黑麦 链接: https://blog.csdn.net/qq

tensorflow之分类学习

╄→гoц情女王★ 提交于 2019-12-27 10:52:54
写在前面的话 MNIST教程是tensorflow中文社区的第一课,例程即训练一个 手写数字识别 模型: http://www.tensorfly.cn/tfdoc/tutorials/mnist_beginners.html 参考视频: https://morvanzhou.github.io/tutorials/machine-learning/tensorflow/5-01-classifier/ MNIST编程 代码全文 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets('MNIST_data',one_hot = True) def add_layer(inputs, in_size, out_size, activation_function=None): Weights = tf.Variable(tf.random_normal([in_size, out_size])) biases = tf.Variable(tf.zeros([1, out_size]) + 0.1) Wx_plus_b = tf.matmul(inputs, Weights) + biases if

TensorFlow实现LeNet5模型

99封情书 提交于 2019-12-26 20:34:00
# -*- coding: utf-8 -*- import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # 获取mnist数据 mnist = input_data . read_data_sets ( "MNIST_data/" , one_hot = True ) # 注册默认session 后面操作无需指定session 不同sesson之间的数据是独立的 sess = tf . InteractiveSession () # 构造参数W函数 给一些偏差0.1防止死亡节点 def weight_variable ( shape ): initial = tf . truncated_normal ( shape , stddev = 0.1 ) return tf . Variable ( initial ) # 构造偏差b函数 def bias_variable ( shape ): initial = tf . constant ( 0.1 , shape = shape ) return tf . Variable ( initial ) # x是输入,W为卷积参数 如[5,5,1,30] 前两个表示卷积核的尺寸 # 第三个表示通道channel

Generating Grayscale Values Of An Image

你离开我真会死。 提交于 2019-12-25 06:23:34
问题 I have trained a model (on the famous MNIST data) to learn to identify images of digits from 0 to 9. The intensity values were provided as feature sets. Now I want to test the model myself, for that I want to say write a number on MS Paint and run through the model. I know how to use PNG package to convert the image to grayscale values but I need help in creating the image with similar range of grayscle. Currently when I try to draw in Paint it ranges from 0:255, unlike in the training set

Uninitialized value error while using Adadelta optimizer in Tensorflow

我的梦境 提交于 2019-12-25 05:09:41
问题 I am trying to build a CNN using Adagrad optimizer but am getting the following error. tensorflow.python.framework.errors.FailedPreconditionError: Attempting to use uninitialized value Variable_7/Adadelta [[Node: Adadelta/update_Variable_7/ApplyAdadelta = ApplyAdadelta[T=DT_FLOAT, _class=["loc:@Variable_7"], use_locking=false, _device="/job:localhost/replica:0/task:0/cpu:0"](Variable_7, Variable_7/Adadelta, Variable_7/Adadelta_1, Adadelta/lr, Adadelta/rho, Adadelta/epsilon, gradients/add_3

TensorFlow Training CNN on Custom Images

十年热恋 提交于 2019-12-25 00:13:31
问题 All the tensorflow tutorials do a great job, however, they all use preprocessed downloadable datasets that work out of the box. Their tutorial on MNIST is the perfect example. For a school project, 4 others and I have been assigned to train a CNN on supplied data in the form of PNG images. It's just a directory with 150 images. The labels are contained in the image file names. The way the codes sits now we are getting an error which I will include below. We followed the MNIST code found here:

cannot reshape array of size 64 into shape (28,28)

我的未来我决定 提交于 2019-12-25 00:00:17
问题 Not able to reshape the image in mnist dataset using sklean This is the starting portion of my code just load the data some_digit = X[880] some_digit_image = some_digit.reshape(28, 28) ERROR PART ValueError Traceback (most recent call last) <ipython-input-15-4d618bdb57bc> in <module> 1 some_digit = X[880] ----> 2 some_digit_image = some_digit.reshape(28,28) ValueError: cannot reshape array of size 64 into shape (28,28) 回答1: You can only reshape it into a 8, 8 array. 8x8=64 回答2: try: some