本文整理匯總了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