What are Artificial Neural Networks?

Raajeev H Dave (AI Man)
6 min readOct 27, 2024

Let’s break down Artificial Neural Networks (ANNs) using a simple example.

Artificial Neural Networks are computer systems inspired by the way our brain works. Just like our brain has neurons that communicate with each other, ANNs have small units called perceptrons (like mini-neurons) that work together to solve problems.

How do They Work?

  1. Inputs: Imagine you are trying to predict whether it will rain tomorrow based on certain factors, like humidity, temperature, and wind speed. These factors are your inputs.
  2. Weights: Each input is assigned a weight that shows its importance. For example, humidity might be more important than temperature, so it could have a higher weight.
  3. Weighted Sum: The perceptrons calculate the weighted sum of the inputs. This means they multiply each input by its weight and add them all together. For example:
  4. Activation Function: After calculating the weighted sum, the perceptron uses a non-linear activation function. This function decides whether the perceptron “fires” (produces an output) or not. A simple way to think about it is that if the weighted sum is above a certain threshold, the output will be “Yes, it will rain!” If it’s below, the output will be “No, it won’t rain.”

Summary with an Example

  • Inputs: Humidity = 0.8, Temperature = 0.6, Wind Speed = 0.4
  • Weights: Humidity = 0.5, Temperature = 0.3, Wind Speed = 0.2
  • Weighted Sum: 0.660.660.66
  • Activation Function: If the sum is greater than 0.5, output is 1 (it will rain).

Examples…

1.Image Classification: Recognizing Handwritten Digits

What it Does:

An Artificial Neural Network (ANN) can be trained to recognize handwritten numbers (0–9) from images, like those found in the MNIST dataset.

How it Works:

1. Input Layer

- Each pixel in the image is treated as a separate input node in the Input Layer. For example, in a 28x28 pixel image (used in the MNIST dataset), there would be 784 input nodes, each representing one pixel.

- Each pixel has a grayscale value (between 0 and 255) that the network uses as input to determine the digit’s shape.

2. Hidden Layers

- The network has one or more hidden layers that help it learn features, like edges, curves, or parts of the digit shape (e.g., loops or straight lines).

- The hidden layers use weights and biases to adjust the importance of each pixel and pattern as it passes through the network. Over time, the network learns to identify key parts of each digit.

3. Output Layer

- The output layer has 10 nodes, each representing one digit from 0 to 9.

- After processing the image through the network, each node in the output layer will have a value representing the probability that the image corresponds to that digit.

- The network picks the digit with the highest probability as its final prediction.

2.Predicting House Prices: Estimating the Cost of a House

What it Does:

An Artificial Neural Network (ANN) can be trained to predict house prices based on features like size, location, and number of rooms.

How it Works:

1. Input Layer

- Each input node represents a feature related to the house, like:

- Size: Area in square feet.

- Number of Bedrooms: Count of bedrooms.

- Location: Encoded as numerical values or categories.

- Age: Age of the house in years.

- These features serve as inputs for the network, with each one representing a specific factor that may affect the house’s price.

2. Hidden Layers

- The ANN has one or more hidden layers that help it learn complex relationships between features and house prices.

- Through training on historical house data, the network adjusts weights and biases to understand how each feature (or a combination of features) influences the price.

- For example, it might learn that larger square footage increases the price or that houses in certain locations tend to be more valuable.

3. Output Layer

- The output layer has a single node representing the predicted price of the house.

- After passing the inputs through the network, this node provides a price prediction based on the learned patterns in the data.

3.Sentiment Analysis: Determining Sentiment from Text

What it Does:

An Artificial Neural Network (ANN) can analyze text to determine whether the sentiment is positive, negative, or neutral.

How it Works:

1. Input Layer

- Each word in a sentence is converted into a numerical representation. Common methods for this include:

- Word Embeddings: Words are represented as vectors, capturing meaning and similarity between words.

- For example, the sentence “I love this product” might be broken down into word vectors for “I,” “love,” “this,” and “product” and fed into the network.

2. Hidden Layers

- The ANN has one or more hidden layers that help it learn the context and meaning of words in a sentence.

- Through training, the network learns patterns related to sentiment, like recognizing positive words (e.g., “love,” “excellent”) or negative words (e.g., “hate,” “poor”).

- It also learns to understand word combinations and their context to identify sentiment more accurately, even in sentences with mixed meanings.

3. Output Layer

- The output layer has three nodes representing the possible sentiments: positive, negative, and neutral.

- After processing the input through the network, each node provides a probability for each sentiment.

- The sentiment with the highest probability is chosen as the output.

4.Medical Diagnosis: Diagnosing Diseases

What it Does:

Artificial Neural Networks (ANNs) can assist doctors in diagnosing diseases by analyzing symptoms, medical test results, and patient history.

How it Works:

1. Input Layer

- Each input node represents a different feature related to the patient’s health, such as:

- Symptoms: Descriptions like fever, cough, or fatigue.

- Test Results: Results from medical tests (e.g., blood pressure, cholesterol levels).

- Patient History: Information on any previous medical conditions or family history of diseases.

- These inputs provide the ANN with all the data necessary to assess the patient’s health.

2. Hidden Layers

- The ANN has one or more hidden layers that help it learn patterns and associations between symptoms, test results, and diseases.

- During training, the network is exposed to data from many patients, learning which combinations of features are associated with specific diagnoses.

- For example, it might learn that certain test results combined with specific symptoms often indicate a particular illness.

3. Output Layer

- The output layer provides a list of possible diagnoses, with each node representing a different disease.

- Each node’s output gives the likelihood of that disease based on the inputs.

- The network ranks potential diagnoses by probability, helping doctors see the most likely conditions at the top of the list.

5.Stock Price Prediction: Forecasting Future Stock Prices

What it Does:

Artificial Neural Networks (ANNs) can be used to predict future stock prices based on patterns in historical data.

How it Works:

1. Input Layer

- Each input node represents a different feature related to stock performance, such as:

- Previous Stock Prices: Past daily, weekly, or monthly closing prices.

- Financial Indicators: Metrics like trading volume, moving averages, and market trends.

- External Factors: Optional factors like economic indicators or industry news.

- These inputs help the ANN analyze multiple aspects of stock movement over time.

2. Hidden Layers

- The ANN has one or more hidden layers where it learns complex trends and patterns in the historical data.

- During training, the network identifies relationships between past stock prices and financial indicators, recognizing patterns that often precede price changes.

- For example, it may learn that when certain indicators align (e.g., a moving average crosses a certain threshold), there is a trend for prices to increase or decrease.

3. Output Layer

- The output layer provides the predicted stock price for the next day, week, or other time period.

- After processing all inputs, the network generates a prediction based on the learned patterns.

- This predicted price is intended to indicate the stock’s likely future value, helping investors make informed decisions.

Explanation of ANN Structure

  • Input Layer: The first layer that receives data.
  • Hidden Layers: Intermediate layers that process inputs. The more hidden layers, the more complex patterns can be learned.
  • Output Layer: The final layer that provides the result.

Key Concepts

  • Neurons: Basic units of an ANN, similar to biological neurons.
  • Weights: Connections between neurons that are adjusted during training to improve accuracy.
  • Activation Function: Determines if a neuron should be activated (like a switch) based on input.

These examples can help students understand how ANNs can be applied in real-world scenarios and the basic concepts behind them!

Conclusion

So, an Artificial Neural Network works like this: it takes multiple inputs, considers how important each one is (through weights), adds them up, and then uses a function to determine if the output should be positive or negative (like predicting rain). This simple model helps machines learn from data and make decisions, just like we do!

--

--

No responses yet