Hands-On Neural Networks with Keras
上QQ阅读APP看书,第一时间看更新

Loading the data

Now, let's load in the data and split it up. Thankfully, MNIST is one of the core datasets that's already implemented in Keras, allowing a nice one-liner import, which also lets us split up our data in training and test sets. Of course, real-world data is not that easy to port and split up. A lot of useful tools exist for this purpose in Keras.utils, which we will cover briefly later, but also encourage you to explore. Alternatively, other ML libraries such as scikit-learn come with some handy tools (such as train_test_split, MinMaxScaler, and normalizer, to name a few methods), which, as their names indicate, let you split up, scale, and normalize your data as often required to optimize neural network training. Let's import and load the datasets, as follows:

from keras.datasets import mnist
(x_train, y_train),(x_test, y_test)= fashion_mnist.load_data()