Search code examples
pythonkerasimportneural-networkmnist

mnist raising an error even after i've already installed it's module


so i'm trying to import mnist to use it in a simple CNN example, but it's not being recognized, here is the code that i'm using:

from keras.models import Model
from keras.layers import Input, merge

from keras.layers.core import Flatten, Dense, Dropout, Activation
from keras.layers.convolutional import Convolution2D, MaxPooling2D, AveragePooling2D
from keras.layers.normalization import BatchNormalization
import keras.utils.np_utils as kutils
from keras.utils.vis_utils import plot_model, model_to_dot

import MNIST as dc
import numpy as np

batch_size = 128 # 128
nb_epoch = 100 # 12
img_rows, img_cols = 28, 28

trainData = dc.convertPandasDataFrameToNumpyArray(dc.loadTrainData(describe=False))
trainX = trainData[:, 1:].reshape(trainData.shape[0], 1, img_rows, img_cols)
trainX = trainX.astype(float)
trainX /= 255.0

the error that i get:

ModuleNotFoundError: No module named 'MNIST'

i've already installed the MNIST using pip but didn't help at all


Solution

  • I've never seen the MNIST being imported this way. Why don't you just use this since you're already using Keras?

    from keras.datasets import mnist
    
    (x_train, y_train), (x_test, y_test) = mnist.load_data()