How to use neural network

simple examples of how to apply neural network

In this tutorial, we will introduce some simple examples in order to understand how to use neural network. The examples show in the following sections are for intuitive understanding of how to use neural network. Note that these examples are not based on actual problem, but rather for intuitive understanding.

Example 1 Blood Sugar Control

Suppose person A wants to control his blood sugar due to his drowsiness problem. If he takes X [calories] of food, then his blood sugar will rise to Y[mg/dL]. His aim is to control the blood sugar. Let’s suppose Y and X are in a static relation (meaning if X is inputted, then we get the result of Y immediately.)

For example, if A’s food consumption and blood sugar is in a linear relationship, then we can express the relation as a simple linear equation of Y=aX+b, a and b representing the slop and intercept respectively. If so, A’s blood sugar can be forecasted easily.

However, like A, most of the functions and system that exist in the real world are non-linear. In order to precisely model using non-linear relative data, we need lots of data. We also need to make assumptions on what equations fit the best with data. Some might be easy to express using a simple non-linear function, but if we have a complex non-linear, structured data then it is hard to define that function. For example, we may be able to find the function that fits the line as show on the left of the diagram below, but when we have data as shown on the right side, assuming what function fit data might be difficult to find.

Another approach to modeling is understanding the mechanism inside A and build a mathematical model for each mechanism. However, the model as total may deviate from A, since the mechanism and structure inside A might be difficult and the parameters are mostly unknown.

In order to solve the modeling problem of person A, neural network is one solution. If we have large amount of data, we don’t need to know the structure inside of the target function.

Also, if we use blood sugar Y[mg/dL] as input and food amount X [calories] as output when learning, we can build a model as a controller. In other words, we can calculate how much X[mg/dL] is needed to suppress the blood sugar y[mg/dL] under Yr[mg/dL].

Example 2 Predicting Traffic Condition

Another way of using neural network is building a prediction model. For example, suppose we have a dataset of number, density, and average velocity of cars in a certain area, with traffic condition data corresponding to those data, and we want to predict the traffic condition.

For prediction purpose, we can use dataset of number, density, and average velocity of cars as input and the traffic condition that’s some time step further as output. By building this model, we can predict the traffic condition before traffic occurs. For further application, we can also use this model to alert cars that are that are going to pass this certain area before traffic occurs.

Example 3 Facial Image Classification of Humans, Cats and Dogs

Image classification now-a-days are a prime example of neural network. For example, assume we have multiple facial images of humans, cats, and dogs. As the traditional method, we would discuss what features human faces have at first, and then find ways to extract those features. We would also have to consider how to extract features from cats and dogs as well, since they have different facial properties. As a result, it would be necessary to implement multiple feature extraction algorithm for classification purpose. The more classification, the more feature extraction algorithm we needed.

However, with neural network, we can get a classification function that distinguishes the faces of humans, cats, and dogs by learning input and output of the image, which in return reduces the necessity of considering what feature extraction to implement inside the model.

Can neural network learn anything?

As of until now, we’ve discussed what neural network can do. Despites its capability of learning, there are certain situations neural network will not learn properly, such as predicting with small amount of data. Even if it learned, it may not be sufficient as a model. For example, we can have the neural network learn over 2 unrelated data, such as ‘precipitation’ and ‘stock price’, and still not function well as a model for prediction purpose. Sometimes, we have to consider some conditions such as if it is learnable or not, or whether we need preprocessing or not. In the first example, we assumed that the relationship between food amount and blood sugar was static, but in reality, its dynamical (meaning time factor is considered, but in brief, function that have time-delayed output), thus we should also consider time-delays. When learning with neural network, we recommend that there is some kind of prior knowledge to support the relationship between the input and output data.


When we have datasets of input and output, we would build a mathematical model to represent the relationship between these data. However, there are times where complex processing is need. In contrast, neural network can learn the relationship between these data without prior knowledge, for example mathematical representation. With large number of datasets, we can also learn models which can be used for prediction or classification. In this tutorial, we showed examples where neural network can be used. However, whether it can learn properly depends on the relationship between the dataset. For example, we cannot create an adequate model with 2 unrelated data, for instance ‘weather’ and ‘stock price’. Therefore, it is recommended that we consider some kind of relationship between data before learning.

In this tutorial, we introduced some examples of how to use neural network, though the examples presented in this tutorial are only part of the many examples. At ‘’, we will introduce many ways of how to use neural network, as well as many variational structure, and we hope it helps readers for further understanding.