What are Neural Networks đ§
Neural networks a.k.a artificial neural networks (ANNs) are a subset of AI and are at the heart of deep learning algorithms. Their name and structure are inspired by the human brain, mimicking the way that biological neurons signal to one another.
Artificial neural networks (ANNs) are comprised of node layers, containing an input layer, one or more hidden layers, and an output layer. Each node, or artificial neuron, connects to another and has an associated weight and threshold. If the output of any individual node is above the specified threshold value, that node is activated, sending data to the next layer of the network. Otherwise, no data is passed along to the next layer of the network.
Neural networks rely on training data to learn and improve their accuracy over time. However, once these learning algorithms are fine-tuned for accuracy, they are powerful tools in computer science and artificial intelligence, allowing us to classify and cluster data at a high velocity. Tasks in speech recognition or image recognition can take minutes versus hours when compared to the manual identification by human experts. One of the most well-known neural networks is Googleâs search algorithm.
How do they workâŠđ€
Think of each individual node as its own linear regression model, composed of input data, weights, a bias and an output. The formula would look something like this:
Once an input layer is determined, weights are assigned. These weights help determine the importance of any given variable, with larger ones contributing more significantly to the output compared to other inputs. All inputs are then multiplied by their respective weights and then summed. Afterwards, the output is passed through an activation function, which determines the output. If that output exceeds a given threshold, it âfiresâ (or activates) the node, passing data to the next layer in the network. This results in the output of one node becoming in the input of the next node. This process of passing data from one layer to the next layer defines this neural network as a feedforward network.
Letâs break down what one single node might look like using binary values. We can apply this concept to a more tangible example, like whether you should go surfing (Yes: 1, No: 0). The decision to go or not to go is our predicted outcome or y-hat. Letâs assume that there are three factors influencing your decision-making:
- Are the waves good? (Yes: 1, No: 0)
- Is the line-up empty? (Yes: 1, No: 0)
- Has there been a recent shark attack? (Yes: 0, No: 1)
Then, letâs assume the following, giving us the following inputs:
- X1 = 1, since the waves are pumping
- X2 = 0, since the crowds are out
- X3 = 1, since there hasnât been a recent shark attack
Now, we need to assign some weights to determine importance. Larger weights signify that particular variables are of greater importance to the decision or outcome.
- W1 = 5, since large swells donât come around often
- W2 = 2, since youâre used to the crowds
- W3 = 4, since you have a fear of sharks
Finally, weâll also assume a threshold value of 3, which would translate to a bias value of â3. With all the various inputs, we can start to plug in values into the formula to get the desired output.
Y-hat = (1*5) + (0*2) + (1*4) â 3 = 6
If we use the activation function from the beginning of this section, we can determine that the output of this node would be 1, since 6 is greater than 0. In this instance, you would go surfing; but if we adjust the weights or the threshold, we can achieve different outcomes from the model. When we observe one decision, like in the above example, we can see how a neural network could make increasingly complex decisions depending on the output of previous decisions or layers.
In the example above, we used perceptrons to illustrate some of the mathematics at play here, but neural networks leverage sigmoid neurons, which are distinguished by having values between 0 and 1. Since neural networks behave similarly to decision trees, cascading data from one node to another, having x values between 0 and 1 will reduce the impact of any given change of a single variable on the output of any given node, and subsequently, the output of the neural network.
As we start to think about more practical use cases for neural networks, like image recognition or classification, weâll leverage supervised learning, or labelled datasets, to train the algorithm. As we train the model, weâll want to evaluate its accuracy using a cost (or loss) function. This is also commonly referred to as the mean squared error (MSE). In the equation below,
- i represents the index of the sample,
- y-hat is the predicted outcome,
- y is the actual value, and
- m is the number of samples.
Ultimately, the goal is to minimize our cost function to ensure the correctness of fit for any given observation. As the model adjusts its weights and bias, it uses the cost function and reinforcement learning to reach the point of convergence or the local minimum. The process in which the algorithm adjusts its weights is through gradient descent, allowing the model to determine the direction to take to reduce errors (or minimize the cost function). With each training example, the parameters of the model adjust to gradually converge at the minimum.
Most deep neural networks are feedforward, meaning they flow in one direction only, from input to output. However, you can also train your model through backpropagation; that is, move in the opposite direction from output to input. Backpropagation allows us to calculate and attribute the error associated with each neuron, allowing us to adjust and fit the parameters of the model(s) appropriately.
Common types of NNs đ±
Neural networks can be classified into different types, which are used for different purposes. While this isnât a comprehensive list of types, the below would be representative of the most common types of neural networks that youâll come across for its common use cases:
The perceptron is the oldest neural network, created by Frank Rosenblatt in 1958. It has a single neuron and is the simplest form of a neural network:
Feedforward neural networks, or multi-layer perceptrons (MLPs), are what weâve primarily been focusing on within this blog. They are comprised of an input layer, a hidden layer or layers, and an output layer. While these neural networks are also commonly referred to as MLPs, itâs important to note that they are actually comprised of sigmoid neurons, not perceptrons, as most real-world problems are nonlinear. Data usually is fed into these models to train them, and they are the foundation for computer vision, natural language processing, and other neural networks.
Convolutional neural networks (CNNs) are similar to feedforward networks, but theyâre usually utilized for image recognition, pattern recognition, and computer vision. These networks harness principles from linear algebra, particularly matrix multiplication, to identify patterns within an image.
Recurrent neural networks (RNNs) are identified by their feedback loops. These learning algorithms are primarily leveraged when using time-series data to make predictions about future outcomes, such as stock market predictions or sales forecasting.
Use casesâš
Instagram, acquired by Facebook back in 2012, uses deep learning by making use of a connection of recurrent neural networks to identify the contextual meaning of an emoji â which has been steadily replacing slangs (for instance, a laughing emoji could replace âROFLâ).
By algorithmically identifying the sentiments behind emojis, Instagram creates and auto-suggests emojis and emoji related hashtags. This may seem like a minor application of AI, but being able to interpret and analyze this emoji-to-text translation at a larger scale sets the basis for further analysis on how people use Instagram.
Online Shopping
Do you find yourself in situations where youâre set to buy something, but you end up buying a lot more than planned, thanks to some super-awesome recommendations?
Yeah, blame neural networks for that. By making use of neural network and its learnings, the e-commerce giants are creating Artificial Intelligence systems that know you better than yourself. Letâs see how:
Search
Your Amazon searches (âearphonesâ, âpizza stoneâ, âlaptop chargerâ, etc) return a list of the most relevant products related to your search, without wasting much time. In a description of its product search technology, Amazon states that its algorithms learn automatically to combine multiple relevant features. It uses past patterns and adapts to what is important for the customer in question.
And what makes the algorithms âlearnâ? You guessed it right â Neural Networks!
Recommendations
Amazon shows you recommendations using its âcustomers who viewed this item also viewedâ, âcustomers who bought this item also boughtâ, and also via curated recommendations on your homepage, on the bottom of the item pages, and through emails. Amazon makes use of Artificial Neural Networks to train its algorithms to learn the pattern and behaviour of its users. This, in turn, helps Amazon provide even better and customized recommendations.
Voice-to-Text
One of the more common features on smartphones today is voice-to-text conversion. Simply pressing a button or saying a particular phrase (âOk Googleâ, for example), lets you start speaking to your phone and your phone converts the audio into text. Google makes use of artificial neural networks in recurrent connection to power voice search. Microsoft also claims to have developed a speech-recognition system â using Neural Networks, that can transcribe conversations slightly more accurately than humans.
Smart Personal Assistants
With the voice-to-text technology becoming accurate enough to rely on for basic conversations, it is turning into the control interface for a new generation of personal assistants. Initially, there were simpler phone assistants â Siri and Google Now (now succeeded by the more sophisticated Google Assistant), which could perform internet searches, set reminders, and integrate with your calendar. Amazon expanded upon this model with the announcement of complementary hardware and software components â Alexa, and Echo (later, Dot).
Thank You! đ„°