本文整理汇总了Python中mnist.test_images方法的典型用法代码示例。如果您正苦于以下问题:Python mnist.test_images方法的具体用法?Python mnist.test_images怎么用?Python mnist.test_images使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mnist
的用法示例。
在下文中一共展示了mnist.test_images方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_data
# 需要导入模块: import mnist [as 别名]
# 或者: from mnist import test_images [as 别名]
def create_data(X: dt.Frame = None):
train_images = mnist.train_images()
train_labels = mnist.train_labels()
test_images = mnist.test_images()
test_labels = mnist.test_labels()
train_images = train_images.reshape((len(train_images), -1))
test_images = test_images.reshape((len(test_images), -1))
train_data = pd.DataFrame(train_images)
test_data = pd.DataFrame(test_images)
train_data = train_data.add_prefix('b')
test_data = test_data.add_prefix('b')
train_data["number"] = train_labels
test_data["number"] = test_labels
train_data = train_data.apply(np.int8)
test_data = test_data.apply(np.int8)
return {"mnist_train": train_data, "mnist_test": test_data}
示例2: _get_test_dmatrix
# 需要导入模块: import mnist [as 别名]
# 或者: from mnist import test_images [as 别名]
def _get_test_dmatrix() -> xgb.DMatrix:
"""
Get MNIST test data and labels as a XGBoost DMatrix which is an
internal data structure that used by XGBoost optimized for both
memory efficiency and training speed.
The mnist pypi python package is used to load the MNIST database.
:see: http://yann.lecun.com/exdb/mnist/ MNIST database
:see: https://github.com/datapythonista/mnist
The MNIST database is a dataset of handwritten digits with:
60,000 training samples
10,000 test samples
Each image is represented by:
28x28 pixels shape (1, 784)
values are 0 - 255 representing the pixels grayscale value
:return: XGBoost.DMatrix containing the MNIST database test data and labels
"""
X_test_data_3D_nda = mnist.test_images()
y_test = mnist.test_labels()
_logger.info('X_test_data_3D_nda.shape: {}'.format(X_test_data_3D_nda.shape))
# convert the MNIST database 3D numpy arrays (samples * rows * columns)
# to machine learning 2D arraya (samples * features)
X_test = X_test_data_3D_nda.reshape((
X_test_data_3D_nda.shape[0],
X_test_data_3D_nda.shape[1] * X_test_data_3D_nda.shape[2]
))
_logger.info('X_test.shape: {}'.format(X_test.shape))
_logger.info('y_test.shape: {}'.format(y_test.shape))
# use DMatrix for xgboost
dtest = xgb.DMatrix(X_test, label=y_test)
return dtest
示例3: reshapedMnistData
# 需要导入模块: import mnist [as 别名]
# 或者: from mnist import test_images [as 别名]
def reshapedMnistData(train_images, train_labels, test_images, test_labels):
train_images = reshapeImages(train_images)
train_labels = reshapeImages(train_labels)
test_images = reshapeImages(test_images)
test_labels = reshapeImages(test_labels)
return train_images, train_labels, test_images, test_labels
示例4: getMnistData
# 需要导入模块: import mnist [as 别名]
# 或者: from mnist import test_images [as 别名]
def getMnistData(reshaped=True):
mnist.temporary_dir = lambda: r'.\dataset'
train_images = mnist.train_images()
train_labels = mnist.train_labels()
test_images = mnist.test_images()
test_labels = mnist.test_labels()
if reshaped == True:
return reshapedMnistData(train_images, train_labels, test_images, test_labels)
else:
return train_images, train_labels, test_images, test_labels