Python mnist.train_images() Examples
The following are 8
code examples of mnist.train_images().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
mnist
, or try the search function
.
Example #1
Source File: mnist.py From driverlessai-recipes with Apache License 2.0 | 5 votes |
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}
Example #2
Source File: pipeline_train.py From models with Apache License 2.0 | 5 votes |
def _get_train_dmatrix() -> xgb.DMatrix: """ Get MNIST training 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 training data and labels """ X_train_data_3D_nda = mnist.train_images() y_train = mnist.train_labels() _logger.info('X_train_data_3D_nda.shape: {}'.format(X_train_data_3D_nda.shape)) # convert the MNIST database data 3D numpy arrays (samples * rows * columns) # to machine learning 2D arraya (samples * features) X_train = X_train_data_3D_nda.reshape(( X_train_data_3D_nda.shape[0], X_train_data_3D_nda.shape[1] * X_train_data_3D_nda.shape[2] )) _logger.info('X_train.shape: {}'.format(X_train.shape)) _logger.info('y_train.shape: {}'.format(y_train.shape)) # use DMatrix for xgboost dtrain = xgb.DMatrix(X_train, label=y_train) return dtrain
Example #3
Source File: pipeline_train.py From models with Apache License 2.0 | 5 votes |
def _get_train_dmatrix() -> xgb.DMatrix: """ Get MNIST training 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 training data and labels """ X_train_data_3D_nda = mnist.train_images() y_train = mnist.train_labels() _logger.info('X_train_data_3D_nda.shape: {}'.format(X_train_data_3D_nda.shape)) # convert the MNIST database data 3D numpy arrays (samples * rows * columns) # to machine learning 2D arraya (samples * features) X_train = X_train_data_3D_nda.reshape(( X_train_data_3D_nda.shape[0], X_train_data_3D_nda.shape[1] * X_train_data_3D_nda.shape[2] )) _logger.info('X_train.shape: {}'.format(X_train.shape)) _logger.info('y_train.shape: {}'.format(y_train.shape)) # use DMatrix for xgboost dtrain = xgb.DMatrix(X_train, label=y_train) return dtrain
Example #4
Source File: pipeline_train.py From models with Apache License 2.0 | 5 votes |
def _get_train_dmatrix() -> xgb.DMatrix: """ Get MNIST training 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 training data and labels """ X_train_data_3D_nda = mnist.train_images() y_train = mnist.train_labels() _logger.info('X_train_data_3D_nda.shape: {}'.format(X_train_data_3D_nda.shape)) # convert the MNIST database data 3D numpy arrays (samples * rows * columns) # to machine learning 2D arraya (samples * features) X_train = X_train_data_3D_nda.reshape(( X_train_data_3D_nda.shape[0], X_train_data_3D_nda.shape[1] * X_train_data_3D_nda.shape[2] )) _logger.info('X_train.shape: {}'.format(X_train.shape)) _logger.info('y_train.shape: {}'.format(y_train.shape)) # use DMatrix for xgboost dtrain = xgb.DMatrix(X_train, label=y_train) return dtrain
Example #5
Source File: getdata.py From Neural-Networks-from-scratch with The Unlicense | 5 votes |
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
Example #6
Source File: getdata.py From Neural-Networks-from-scratch with The Unlicense | 5 votes |
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
Example #7
Source File: getdata.py From Neural-Networks-from-scratch with The Unlicense | 5 votes |
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
Example #8
Source File: getdata.py From Neural-Networks-from-scratch with The Unlicense | 5 votes |
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