The Scala REPL is a great tool for trying out code interactively.
It lets you write expressions in a terminal window, and immediately prints the return value as well as any outputs to the console.
Whether you're learning the language, exploring an API, or sketching out a new idea, the immediate feedback after evaluating an expression is a great enabler for hands-on learning and rapid prototyping.
The easiest way to get started is the default REPL because it's part of the Scala distribution and is also available in any SBT project as the console command.
The default REPL lacks many convenience features though.
Ammonite is a modern REPL implementation created by Li Haoyi. It comes with many features that make working in the REPL more convenient. Probably the most important one is dynamic maven dependency loading in the REPL itself (through Coursiermore ...
In this post, we're going to create an off the shelve object detector using OpenCV and TensorFlow for Scala.
The detector will be able to detect common objects like people in still images and videos.
It will also be able to run on a live video stream captured from your webcam.
In the previous post we talked about image recognition (or image classification). Image recognition is about recognizing what the content of an image is. In object detection, we want to predict where one or multiple objects are located in an image. Usually when we say object detection we mean recognition and localization together. I.e. we want a neural net to tell us that the image contains a beagle, and to also tell us the location of the beagle within the image.
In most cases, a neural network is trained to predict the coordinates of the rectangle surrounding an object, called bounding box, and to classify the object within that bounding box. The classification part is almost always done using a convolutional …
In the first part of this series, we saw 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.).
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 …
Deep learning is a subset of machine learning, which has seen a tremendous growth in popularity recently. One of the reasons for that growth is that deep learning has brought huge advances to fields such as computer vision, speech recognition or machine translation. Those are fields that are mostly dealing with unstructured data that have traditionally been difficult for computers. Another reason for the success of deep learning, compared to traditional machine learning approaches, is its ability to automatically learn features from raw data, such as images, reducing the need for expensive manual feature engineering and making it applicable to a broader range of domains.
Deep learning is actually just a newer term for modern artificial neural networks. It's called "Deep", because these networks tend to be stacked in a sequence of several successive layers of computation. In a nutshell, common types of deep neural networks can learn to approximate very complex functions by being trained on (usually a lot of) known examples. After being trained, a deep learning model can be applied to previously unseen data and, with high probability, make correct predictions about that data.
Neural networks are not a new idea, they have been around for …