Page 1 of 1

Artificial Neural Network

Posted: Thu Dec 26, 2024 12:06 pm
by GV_kalpana
Artificial Neural Network (ANN): 



                             An Artificial Neural Network (ANN) is a subset of machine learning inspired by the biological neural networks in the brain. It consists of interconnected layers of artificial neurons that process data in a way that mimics human brain function. ANNs are the foundation for deep learning.





 
 
Structure of an ANN 
  1. Input Layer:
    • Accepts input features (e.g., pixel values, numerical data).
    • Each neuron in this layer represents a single feature.
  2. Hidden Layers:
    • Perform computations and extract patterns from the data.
    • Can have one or more layers with multiple neurons.
    • Each neuron applies a weight, bias, and activation function to its input.
  3. Output Layer:
    • Produces the final output.
    • The number of neurons in this layer corresponds to the number of output categories or values.
How ANN Works 
  1. Forward Propagation:
    • Data flows from the input layer through the hidden layers to the output layer.
    • Each neuron applies:
      • z=∑(weights⋅inputs)+biasz = \sum (weights \cdot inputs) + bias
      • output=ActivationFunction(z)output = ActivationFunction(z)
  2. Error Calculation:
    • The difference between the predicted output and actual output is calculated using a loss function (e.g., mean squared error for regression).
  3. Backward Propagation:
    • Adjusts weights and biases using the gradient descent algorithm to minimize the error.
    • Gradients are calculated using the chain rule of calculus.
  4. Training:
    • The process of iteratively updating weights and biases to improve the model’s accuracy.

Common Activation Functions 
  1. Sigmoid:
    • Outputs values between 0 and 1.
    • f(x)=11+e−xf(x) = \frac{1}{1 + e^{-x}}
    • Used in binary classification.
  2. ReLU (Rectified Linear Unit):
    • Outputs xx if x>0x > 0, otherwise 0.
    • f(x)=max⁡(0,x)f(x) = \max(0, x)
    • Efficient for deep networks.
  3. Tanh:
    • Outputs values between -1 and 1.
    • f(x)=ex−e−xex+e−xf(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}}
  4. Softmax:
    • Converts scores into probabilities for multi-class classification.
Advantages of ANN
  1. Learning Complex Patterns:
    • Capable of modeling non-linear relationships.
  2. Scalability:
    • Can handle large datasets and multiple inputs.
  3. Versatility:
    • Suitable for tasks like classification, regression, and clustering.
  4. Automation:
    • Reduces the need for feature engineering compared to traditional machine learning.
Limitations of ANN
  1. Computational Cost:
    • Requires significant processing power and memory.
  2. Data Dependence:
    • Needs a large amount of labeled data for training.
  3. Overfitting:
    • Risk of the model fitting the noise in the training data.
  4. Interpretability:
    • Acts as a "black box," making it difficult to interpret decisions.
Applications of ANN
  1. Image Processing:
    • Object detection, facial recognition.
  2. Natural Language Processing (NLP):
    • Sentiment analysis, language translation.
  3. Healthcare:
    • Predicting diseases, analyzing medical images.
  4. Finance:
    • Fraud detection, stock market prediction.
  5. Marketing:
    • Customer segmentation, recommendation systems.
How to Build an ANN
  1. Choose a Dataset:
    • Example datasets: MNIST (handwritten digits), Titanic (survival prediction).
  2. Preprocess the Data:
    • Normalize or scale features.
    • Split data into training and testing sets.
  3. Design the Network:
    • Define the number of input neurons (features).
    • Add hidden layers and neurons.
    • Select an activation function for each layer.
  4. Compile the Model:
    • Specify the optimizer (e.g., SGD, Adam) and loss function (e.g., MSE, cross-entropy).
  5. Train the Model:
    • Use the training data to adjust weights through forward and backward propagation.
  6. Evaluate and Test:
    • Measure performance on unseen data using metrics like accuracy or RMSE.
Tools for Building ANN 
  1. Frameworks:
    • TensorFlow, Keras, PyTorch, Scikit-learn.
  2. Visualization:
    • TensorBoard, Matplotlib for monitoring training progress.
  3. Datasets:
    • Public datasets from Kaggle, UCI Machine Learning Repository.