In the first part of this series, we've seen a high-level overview of deep learning, and why Scala is a good fit for building neural networks. We also discussed what a deep learning library should provide, and we looked at a few existing libraries. Now it's time to build the canonical "Hello, World!" example for deep learning: Classifying handwritten digits.
Creating a neural network
Building a neural network usually consists of the following steps:
- Determine your goal.
- Prepare the training data (collect, preprocess, vectorize etc.).
- Divide the data into training set/cross-validation set/test set for evaluation.
- Create the neural network architecture.
- Define the types, number and size of layers.
- Define other hyperparameters such as loss function, optimizer, or learning rate.
- Train your model on the training data.
- Evaluate your model on the cross-validation set.
- Depending on the results, repeat steps 3-5 with different hyperparameters, or collect more data until you're satisfied with the results.
- Do a final evaluation on the test set.
In our case, the task is already set: We want to recognize handwritten digits. The second step, data preparation, usually takes most of the effort, but we don't have to worry about it here because it has …more ...