mnist

Why is the result of the code offered by Deep Learning with TensorFlow different from the snapshot in its book

跟風遠走 提交于 2021-02-19 07:49:05
问题 In the first chapter of Deep Learning with TensorFlow , it gives an example on how to build a simple neural network for recognizing handwritten digits. According to its description, the code bundle for the book can be found at GitHub. From the context, I think section Running a simple TensorFlow 2.0 net and establishing a baseline uses the code same with Deep-Learning-with-TensorFlow-2-and-Keras/mnist_V1.py. When I run this example code, it gives me the following output: The snapshot from the

How to fix “numpy.core._exceptions.MemoryError” while performing MNIST digit classifier?

旧时模样 提交于 2021-02-11 14:53:42
问题 I am making a Stochastic Gradient Descent Classifier (SGDClassifier) using scikit- learn. While Fitting my training data (of shape (60000,784)), I am getting memory error. How to fix it? I have already tried switching from 32 bit to 64 bit IDE. And reducing the training data will decrease the performance (that is basically not the option). Code: (Python 3.7) # Classification Problem # Date: 1st September 2019 # Author: Pranay Saha import pandas as pd x_train= pd.read_csv('mnist_train.csv') y

keras mnist.load_data() is superslow and throw an error after some times

醉酒当歌 提交于 2021-02-10 12:30:11
问题 here is the whole code I use import os import numpy as np import matplotlib.pyplot as plt from tqdm import tqdm from keras.layers import Input from keras.models import Model, Sequential from keras.layers.core import Dense, Dropout from keras.layers.advanced_activations import LeakyReLU from keras.datasets import mnist from keras.optimizers import Adam from keras import initializers os.environ["KERAS_BACKEND"] = "tensorflow" np.random.seed(10) random_dim = 100 def load_mnist_data(): # load the

Keras the simplest NN model: error in training.py with indices

允我心安 提交于 2021-02-08 06:14:31
问题 I have read this example https://github.com/fchollet/keras/blob/master/examples/mnist_mlp.py and decide to use this idea to my base because this is the simplest NN for Keras. This is my base https://drive.google.com/file/d/0B-B3QUQOzGZ7WVhzQmRsOTB0eFE/view (you can download my csv file, it's only 83Kb ) This is picture my base: base.shape = (891, 23) import keras from keras.datasets import mnist from keras.models import Sequential from keras.layers import Dense, Dropout from keras.optimizers

Keras the simplest NN model: error in training.py with indices

大城市里の小女人 提交于 2021-02-08 06:14:29
问题 I have read this example https://github.com/fchollet/keras/blob/master/examples/mnist_mlp.py and decide to use this idea to my base because this is the simplest NN for Keras. This is my base https://drive.google.com/file/d/0B-B3QUQOzGZ7WVhzQmRsOTB0eFE/view (you can download my csv file, it's only 83Kb ) This is picture my base: base.shape = (891, 23) import keras from keras.datasets import mnist from keras.models import Sequential from keras.layers import Dense, Dropout from keras.optimizers

How to save trained model in tensorflow?

喜欢而已 提交于 2021-02-07 03:51:33
问题 I wrote a convolutional neural network in tensorflow to perform on the mnist dataset. Everything works just fine, but i want to save the model with the tf.train.Saver(). How am i gonna do it? Here is my code: from __future__ import print_function import tensorflow as tf # Import MNIST data from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("/tmp/data/", one_hot=True) # Parameters learning_rate = 0.001 training_iters = 200000 batch_size = 128 display

How to save trained model in tensorflow?

谁都会走 提交于 2021-02-07 03:48:19
问题 I wrote a convolutional neural network in tensorflow to perform on the mnist dataset. Everything works just fine, but i want to save the model with the tf.train.Saver(). How am i gonna do it? Here is my code: from __future__ import print_function import tensorflow as tf # Import MNIST data from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("/tmp/data/", one_hot=True) # Parameters learning_rate = 0.001 training_iters = 200000 batch_size = 128 display

Convert MNIST data from numpy arrays to original ubyte data

怎甘沉沦 提交于 2021-01-29 20:02:28
问题 I used this code almost exactly, just changing the line: f = gzip.open("../data/mnist.pkl.gz", 'rb') training_data, validation_data, test_data = cPickle.load(f) to these lines: import pickle as cPickle f = gzip.open("mnist.pkl.gz", 'rb') u = cPickle._Unpickler(f) u.encoding='latin1' training_data, validation_data, test_data = u.load() to account for pickling issues.The original mnist.pkl.gz was downloaded from his repo (available here), or the code to generate the .pkl.gz is here. The output

Error defining an input shape in keras for (60000, 28, 28) array

大憨熊 提交于 2021-01-29 05:57:06
问题 I am setting up my first neural network with keras and tensorflow. I got my input into an array of shape (60000, 28, 28), but when I try and feed it to the model I get an error that the input shape is wrong. I have tried multiple different input shapes including (60000, 28, 28) (1, 28, 28) (28, 28) (28, 28, 1) but none of them seem to work. model = kr.Sequential() model.add(InputLayer(input_shape=(60000, 28, 28))) model.add(Dense(units=784, activation='relu')) model.add(Dense(units=392,

Reshape and write ImageDataGenerator output to CSV file

Deadly 提交于 2021-01-07 01:07:08
问题 I'm working with the MNIST data set. I have the training data vectors in one CSV file (i.e. 60,000 rows, each with 784 columns), and the labels in a separate CSV file. I want to bulk up the amount of training data, and append it to the CSV. It has to be done like this, because then the CSV file has to be fed in to a separate pipeline. I originally wrote this script: import keras from keras.preprocessing.image import ImageDataGenerator import pandas as pd X_train = pd.read_csv('train-images