当前位置: 首页>>代码示例>>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;未经允许,请勿转载。