當前位置: 首頁>>代碼示例>>Python>>正文


Python mnist.test_labels方法代碼示例

本文整理匯總了Python中mnist.test_labels方法的典型用法代碼示例。如果您正苦於以下問題:Python mnist.test_labels方法的具體用法?Python mnist.test_labels怎麽用?Python mnist.test_labels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mnist的用法示例。


在下文中一共展示了mnist.test_labels方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_data

# 需要導入模塊: import mnist [as 別名]
# 或者: from mnist import test_labels [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} 
開發者ID:h2oai,項目名稱:driverlessai-recipes,代碼行數:24,代碼來源:mnist.py

示例2: _get_test_dmatrix

# 需要導入模塊: import mnist [as 別名]
# 或者: from mnist import test_labels [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 
開發者ID:PipelineAI,項目名稱:models,代碼行數:39,代碼來源:pipeline_train.py

示例3: reshapedMnistData

# 需要導入模塊: import mnist [as 別名]
# 或者: from mnist import test_labels [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 
開發者ID:veb-101,項目名稱:Neural-Networks-from-scratch,代碼行數:8,代碼來源:getdata.py

示例4: getMnistData

# 需要導入模塊: import mnist [as 別名]
# 或者: from mnist import test_labels [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 
開發者ID:veb-101,項目名稱:Neural-Networks-from-scratch,代碼行數:12,代碼來源:getdata.py


注:本文中的mnist.test_labels方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。