core.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:nn-iterated-projections 作者: jn2clark 项目源码 文件源码
def get_data(n_train, n_test, nb_classes):
    # the data, shuffled and split between train and test sets
    (X_train, y_train), (X_test, y_test) = mnist.load_data()
    img_rows, img_cols = (28,28)
    # make some that are the same
    X_digits = {ind:X_train[np.where(y_train == ind)] for ind in range(10) }

    X_train = X_train.reshape(X_train.shape[0], 1, img_rows, img_cols)
    X_test = X_test.reshape(X_test.shape[0], 1, img_rows, img_cols)
    X_train = X_train[:n_train]
    X_test = X_test[:n_test]

    X_train = X_train.astype('float32')
    X_test = X_test.astype('float32')
    X_train /= 255
    X_test /= 255
    print(X_train.shape[0], 'train samples')
    print(X_test.shape[0], 'test samples')

    # convert class vectors to binary class matrices
    Y_train = np_utils.to_categorical(y_train[:n_train], nb_classes)
    Y_test = np_utils.to_categorical(y_test[:n_test], nb_classes)

    return X_train, Y_train, X_test, Y_test
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号