Legacy Archive (2018): Originally written in Chinese on doubixie.com and translated into English for this edition. All archive posts · Home

"Deep Learning" Your Deep Learning Models

Original Chinese title: “深度学习”深度学习模型

An interesting take: before applying deep learning, we should do some “deep learning” on our deep learning models. This post is translated from a blog article by Wei G., Head of Machine Learning Research at The Climate Corporation.

More and more companies are building and applying deep learning models in their businesses. Before putting these models into production, several practical issues need to be considered. Dr. Wei G. outlines two scenarios: 1) building a model that works great on training and validation data, only for it to perform poorly once deployed in the real world; 2) getting performance that isn’t noticeably better than traditional machine learning models. While the second scenario makes you reconsider whether to invest more resources in this direction, the first scenario is far riskier—and you might not even realize there is a problem until the model is already in production.

Building Robust Deep Learning Models

Building a strong deep learning model involves far more than taking existing architectures (such as Inception v3, ResNet, LSTM, etc.) and training or fine-tuning them on your own dataset. Those models are a good foundation, but even for the most heavily studied problems like image classification or object detection, fine-tuning them is only the first step. There are still several crucial questions to consider.
First and foremost, regardless of how much data you have, does the distribution of your training data match the distribution in the real-world scenario? Dr. Wei G. mentioned a talk by Andrew Ng he attended a year earlier where Andrew Ng emphasized this exact point. While it sounds obvious in theory, it often doesn’t hold true in practice. We may not even know what the real-world data distribution looks like, and the distribution itself can shift over time.

Deep Learning for Real-Time Crop Disease Identification

Dr. Wei G. uses crop disease identification research as an example—diagnosing diseases in real time from photos taken in the field. Two main sources can cause distribution mismatch. The first is how people take photos. Users may capture photos very differently from the ones used in training. Many convolutional models (CNNs) are not good at handling large variations in scale and rotation. If the difference is substantial, it becomes a problem that neither data augmentation nor transformation-based networks (like Spatial Transformer Networks or deformable convolutional layers) can easily solve. A simple yet effective fix is to collect as much diverse data as possible while also putting constraints on how photos are taken.

1
Figure 1: (a), (b), and (c) show three different types of corn hybrids. Gray Leaf Spot (GLS) symptoms (at a similar stage of the disease) look very different across these hybrids, whereas our training data typically only covers a limited number of varieties.

The second, more challenging issue is that our data only covers a subset of categories (and isn’t representative of all categories). In the disease identification example, when we collect images of corn diseases, the photos come only from certain types of corn seeds. Disease symptoms can look dramatically different across varieties (as shown in Figure 1). Can a model trained this way generalize to most or even all varieties?
The answer is yes, though it likely requires some domain knowledge. The data distributions differ in raw image space, but that doesn’t mean they must differ in every other space. If we can find a feature space where the training data represents the broader population, we can build our model in that space. Another approach is to make the learned features more general rather than tailored to specific hybrids or datasets. This can be achieved by enforcing certain regularizations or partially engineering features instead of letting the model learn everything on its own.

2
Figure 2: Two examples of learned features. The learned features in (a) are more relevant, whereas the features in (b) are less useful across general datasets.

Another interesting question is whether it’s necessary to add extra classes. For example, besides the different diseases, we also need to distinguish healthy leaves from non-leaf images. The non-leaf class can be trained with all kinds of non-leaf photos. However, the healthy leaf class is trickier because it is not a mutually exclusive class. More specifically, a diseased leaf also contains healthy regions (Figure 3). A softmax classifier is discriminative and exclusive by nature—meaning whichever class gets the highest score becomes the final prediction. Whenever the healthy region activates more neurons than the diseased region, the leaf gets classified as healthy.

3
Figure 3: In a typical classification setup, the leaf looks “healthier” than any single disease. In such cases, detection may be more useful.

Object detection might be a good solution to the problem above, which leads to another question: detection vs. classification. Detection can indeed identify and localize multiple objects in an image, but it’s also a much harder problem, so its accuracy isn’t as high right now. Moreover, popular frameworks today—such as R-CNN, SSD, R-FCN, or YOLO—rely on bounding box annotations, which are very expensive to acquire. On top of that, unlike objects in datasets like ImageNet or COCO, many real-world subjects don’t have well-defined shapes. Modeling the conditional probability of a bounding box given a partial object (a sub-window or proposal in an image) doesn’t make much sense. While there are ways to work around this, it adds tremendous complexity and takes a lot of effort.

Other slightly less critical yet very common challenges include: What if intra-class diversity is too high? Would splitting a class into subclasses help produce more consistent features? What if some classes have far fewer training samples than others? And when certain misclassifications are much costlier than others, what is the best way to handle them? These are just a small sample of the many practical questions worth thinking through.

The rise of GANs and their improved variants (such as Wasserstein-GAN) gives us a new way to model data distributions—both by synthesizing new data and by leveraging large amounts of unlabeled data. Although semi-supervised learning still needs further research, it can be worthwhile to experiment with these models to see if unlabeled data improves performance. In addition, Geoffrey Hinton’s CapsNet has drawn a lot of attention. By explicitly modeling the relationships between detected features, it reportedly requires less training data. While it’s an intriguing new direction, CapsNet is still in the exploratory stage and needs further testing on more complex types of images.

4
Figure 4: Examples of GAN-generated images. They enrich the dataset in a different way compared to traditional data augmentation (such as random scaling, cropping, etc.).

While CNNs have successfully extracted useful features across a wide range of vision tasks, the same cannot be said for time-series data. Time-series data is much more problem-dependent, and each type of data can have its own unique characteristics. Just because an LSTM works well in natural language processing doesn’t mean it will work for other kinds of sequential data, and simply adding more hidden units or stacking more LSTM layers may not help. Finding the right architecture can be the first critical—and time-consuming—step.

With all the buzz around AI, people are eager to throw deep learning models at all sorts of problems. However, when solving real-world problems, you should always try traditional machine learning methods first (unless it is a classic deep learning problem). In many cases, a traditional model gives you a better sense of whether a deep neural network is even a promising direction, and it serves as a solid baseline. If a traditional model performs just as well and its features are far easier to interpret, you shouldn’t want to deploy a black-box (or gray-box) model purely for marketing hype. Or if you do, you’d better spend the time to deeply understand the deep learning model you’re using.