所以我试图导入mnist以在一个简单的CNN示例中使用它,但是它未被识别,这是我正在使用的代码:
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
我得到的错误:
ModuleNotFoundError: No module named 'MNIST'
我已经使用pip安装了MNIST,但根本没有帮助
答案 0 :(得分:1)
我从未见过以这种方式导入MNIST。既然已经在使用Keras,为什么不使用它呢?
from keras.datasets import mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()