Docsity

CHEAT SHEET FOR UNIT 2, Cheat Sheet of Artificial Intelligence

Toggle sidebar
bg1
ANN UNIT 2
Perceptron
{Introduction to Perceptron- Perceptron Architecture: Single Neuron Perceptron, Multi Neuron Perceptron -
Perceptron learning rule: Constructing Learning rules, Unified Learning rule, Training multi neuron perceptron
Complexity of perceptron learning-Computational Limits of Perception-Linearly separable functions- Learning XOR-
Feed forward Networks- Back propagation: Chain of rule Calculus, Back-Propagation Computation in Fully-
Connected Multi-layer Perceptron}
Introduction to Perceptron
What is a Perceptron?
โ€ข A Perceptron is one of the simplest types of Artificial Neural Networks (ANN), introduced by Frank
Rosenblatt in 1957.
โ€ข It is a basic model of a neuron designed for binary classification, which means it classifies inputs
into two categories.
โ€ข The perceptron mimics the behavior of a biological neuron but in a simplified mathematical form.
โ€ข It works on the principle of linear classification: it finds a linear boundary (a straight line or
hyperplane) that separates different classes of data.
โ€ข It uses threshold logic units (TLU) with inputs, weights, a bias, a summation function, and an
activation function (step function).
Perceptron Architecture
Single Neuron Perceptron
โ€ข Has one layer of neurons (output layer) connected directly to the inputs.
โ€ข It classifies linearly separable data by computing a weighted sum of the inputs plus a bias and then
applying a step function.
โ€ข The output is binary, typically 0 or 1, depending on whether the input sum crosses a threshold.
โ€ข Basic components:
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d

Partial preview of the text

Download CHEAT SHEET FOR UNIT 2 and more Cheat Sheet Artificial Intelligence in PDF only on Docsity!

ANN UNIT 2

Perceptron

{Introduction to Perceptron- Perceptron Architecture: Single Neuron Perceptron, Multi Neuron Perceptron- Perceptron learning rule: Constructing Learning rules, Unified Learning rule, Training multi neuron perceptron Complexity of perceptron learning-Computational Limits of Perception-Linearly separable functions- Learning XOR- Feed forward Networks- Back propagation: Chain of rule Calculus, Back-Propagation Computation in Fully- Connected Multi-layer Perceptron}

Introduction to Perceptron

What is a Perceptron?

  • A Perceptron is one of the simplest types of Artificial Neural Networks (ANN), introduced by Frank Rosenblatt in 1957.
  • It is a basic model of a neuron designed for binary classification, which means it classifies inputs into two categories.
  • The perceptron mimics the behavior of a biological neuron but in a simplified mathematical form.
  • It works on the principle of linear classification: it finds a linear boundary (a straight line or hyperplane) that separates different classes of data.
  • It uses threshold logic units (TLU) with inputs, weights, a bias, a summation function, and an activation function (step function).

Perceptron Architecture

Single Neuron Perceptron

  • Has one layer of neurons (output layer) connected directly to the inputs.
  • It classifies linearly separable data by computing a weighted sum of the inputs plus a bias and then applying a step function.
  • The output is binary, typically 0 or 1, depending on whether the input sum crosses a threshold.
  • Basic components:

o Inputs (Features) : Numerical values representing the features of data. o Weights : Values that determine the importance of each input. o Bias : Adjusts the activation threshold. o Summation Function : Computes weighted sum $ z = \sum w_i x_i + b $. o Activation Function : Step function (Heaviside) outputs 1 if $ z \geq 0 $, else 0.

Multi Neuron Perceptron (Multi-Layer Perceptron - MLP)

  • Consists of multiple layers: input layer, one or more hidden layers, and output layer.
  • Can handle non-linearly separable problems by learning complex patterns.
  • Uses nonlinear activation functions like sigmoid, ReLU, or softmax.
  • Employs backpropagation for training, adjusting weights and biases by minimizing prediction errors.
  • More computationally intensive but more powerful for complex classification and regression tasks.

How Does Perceptron Work?

  1. Initialization : Randomly initialize weights and bias.
  2. Input Processing : Multiply each input by its corresponding weight.
  3. Summation : Add all weighted inputs and bias to get the net input $ z $.
  4. Activation : Apply the activation function (usually a step function for a single-layer perceptron) to decide output: 1 or 0.
  5. Learning (Training) : Adjust weights and bias iteratively using a learning rule (like Perceptron learning rule) to minimize the difference between predicted output and actual output.

How Does the Perceptron Help?

  • It organizes input data and finds a decision boundary to separate classes.
  • Provides a foundation for understanding more complex neural network models.
  • Enables supervised learning for binary classification problems.
  • Helps in detecting features and making decisions based on those features.

Examples for Clarification:

  • AND Gate Perceptron : Weights and bias can be set/tested such that output is 1 only when both inputs are 1.
  • OR Gate Perceptron : Adjust weights so output is 1 when either input is 1.
  • NOT Gate Perceptron : A single input weight and bias invert the input's output. These gates show how perceptrons can model simple logical operations by learning weights and thresholds

Perceptron Learning Rule: Constructing Learning

Rules, Unified Learning Rule, Training Multi-Neuron

Perceptron

What does the topic say/What is the topic?

This topic covers the learning rules that guide how a perceptron updates its weights and biases during training to improve its performance. Specifically, it discusses:

  • Constructing Learning Rules : Basic rules that modify weights based on errors in prediction, typically used in simple neural networks, like single-layer perceptrons.
  • Unified Learning Rule : A broader framework incorporating different learning rules, often exemplified by backpropagation, used for training multi-layer perceptrons (MLPs).
  • Training Multi-Neuron Perceptron : The process and methods involved in training MLPs with multiple layers to capture complex, non-linear relationships.

How does it work?

Constructing Learning Rules

  • These are error-correcting algorithms designed to adjust weights and biases by comparing predicted output to the actual output.
  • The weight update formula in the Perceptron Learning Rule is: ฮ”๐‘ค๐‘– = ๐œ‚(๐‘ฆ โˆ’ ๐‘ฆห† )๐‘ฅ๐‘–

where: o ฮ”๐‘ค๐‘– is the change for weight ๐‘ค๐‘–, o ๐œ‚ is the learning rate, o ๐‘ฆ is the actual target output, o ๐‘ฆห† is the predicted output, o ๐‘ฅ๐‘– is the input feature value.

  • Other rules include: o Hebbian Learning Rule : Unsupervised; weights are increased if neurons activate simultaneously. o Delta Learning Rule (Widrow-Hoff) : Uses gradient descent with continuous activation functions to minimize overall error. o Correlation Learning Rule : Supervised rule where weight updates depend on input and target values. o Out Star and Competitive Learning Rules : Different update strategies depending on neuron competition or layer structures.

Unified Learning Rule

  • A generalized framework integrating different learning rules, especially for complex architectures.
  • The Backpropagation Algorithm is an example, updating all layers' weights by propagating error gradients backward.
  • Weight update formula used in backpropagation: ๐‘ค๐‘–๐‘—^ ๐‘›๐‘’๐‘ค^ = ๐‘ค๐‘–๐‘—^ ๐‘œ๐‘™๐‘‘^ + ๐œ‚ ๐›ฟ๐‘— ๐‘ฅ๐‘– where: o ๐‘ค๐‘–๐‘— is weight from neuron ๐‘– to neuron ๐‘—, o ๐›ฟ๐‘— is the error term for neuron ๐‘—, o ๐‘ฅ๐‘– is the input from neuron ๐‘–.

Training Multi-Neuron Perceptron

  • It determines the decision boundary and complex functions that separate different classes in data.
  • Backpropagation computes the gradients of error to guide efficient training.

What and how does it help in real-world situations?

  • Enables construction of models that learn from data automatically and improve predictions.
  • Helps in solving classification tasks such as email spam detection, customer churn prediction, and fraud detection.
  • Supports complex function approximation, enabling technologies like facial recognition, voice assistants, and autonomous vehicles.
  • Backpropagation allows models to learn hierarchically, extracting features from raw data for better accuracy.

Quick Teacherโ€™s Explanation

Perceptron learning rules are methods to adjust the networkโ€™s weights so it predicts correctly. In simple perceptrons, weights are updated by looking at the difference between true and predicted outputs, multiplied by inputs and learning rate. The unified learning rule โ€” such as backpropagation โ€” helps train deeper networks with many layers by efficiently calculating error gradients and updating all weights. Training multi-layer perceptrons involves passing data forward, measuring error, using backpropagation to get gradients, and updating weights repeatedly until the network performs well. These learning rules make neural networks learn from examples and solve real-world problems!

Example: Perceptron Learning Rule Step-by-Step

Suppose a perceptron has inputs ๐‘ฅ 1 = 0. 5 , ๐‘ฅ 2 = 0. 3 , initial weights ๐‘ค 1 = 0. 4 , ๐‘ค 2 = โˆ’ 0. 6 , bias ๐‘ = 0. 1 , learning rate ๐œ‚ = 0. 1 , and desired output ๐‘ฆ = 1.

  1. Compute weighted sum: ๐‘ง = ๐‘ค 1 ๐‘ฅ 1 + ๐‘ค 2 ๐‘ฅ 2 + ๐‘ = 0. 4 ร— 0. 5 + (โˆ’ 0. 6 ) ร— 0. 3 + 0. 1 = 0. 2 โˆ’ 0. 18 + 0. 1 = 0. 12
  2. Activation: Since ๐‘ง โ‰ฅ 0 , predicted output ๐‘ฆห† = 1.
  3. Error: ๐‘ฆ โˆ’ ๐‘ฆห† = 1 โˆ’ 1 = 0 (no error).
  4. Weight updates: ฮ”๐‘ค 1 = 0. 1 ร— 0 ร— 0. 5 = 0 , ฮ”๐‘ค 2 = 0. 1 ร— 0 ร— 0. 3 = 0 , ฮ”๐‘ = 0. 1 ร— 0 = 0

Weights are unchanged. If instead predicted output was 0 (error = 1), weights update like: ๐‘ค 1 ๐‘›๐‘’๐‘ค^ = 0. 4 + 0. 1 ร— 1 ร— 0. 5 = 0. 45 , ๐‘ค 2 ๐‘›๐‘’๐‘ค^ = โˆ’ 0. 6 + 0. 1 ร— 1 ร— 0. 3 = โˆ’ 0. 57 , ๐‘๐‘›๐‘’๐‘ค^ = 0. 1 + 0. 1 ร— 1 = 0. 2 This moves weights toward better prediction.

Complexity of Perceptron Learning and

Computational Limits of Perceptron

What does the topic say/What is the topic?

This topic explains the computational complexity involved in training a perceptron and details the limitations inherent to the perceptron model in practice. It covers:

  • The time and space complexity of the perceptron learning algorithm.
  • The theoretical guarantees for convergence.
  • The practical limits of perceptrons, like linear separability requirements, convergence speed, and capacity.
  • How these factors affect real-world applicability of perceptrons.

How does it work?

Complexity of Perceptron Learning

  • Time Complexity: o Depends on number of iterations ๐‘‡, number of data points ๐‘›, and number of features ๐‘‘. o Each iteration processes all data points and updates weights based on features. o Per iteration time is ๐‘‚(๐‘› โ‹… ๐‘‘), so overall complexity is ๐‘‚(๐‘‡ โ‹… ๐‘› โ‹… ๐‘‘). o ๐‘‡ varies based on dataset separability and margin (distance between classes).
  • Space Complexity: o Storing weights vector requires ๐‘‚(๐‘‘). o Storing dataset requires ๐‘‚(๐‘› โ‹… ๐‘‘).
  1. No Hidden Layers: o Single-layer perceptron is limited; it has no capability to learn features by itself or transform inputs non-linearly.
  2. Class Imbalance Ignored: o Does not intrinsically handle imbalanced datasets, which may bias outputs towards majority class.
  3. Computational Inefficiency on Large Datasets: o Iterative updates over entire dataset each iteration become costly with large data. o Variants like stochastic gradient descent (SGD) can help but are outside basic perceptron.

How does the topic help?

  • Offers insight into the efficiency and applicability of perceptron algorithms.
  • Sets realistic expectations about when perceptrons can be employed, given data structure.
  • Guides the choice of using more advanced models for complex or large-scale datasets.
  • Helps understand the theoretical properties that govern learning speed and convergence.

Applications

  • Linearly separable classification problems where perceptrons can quickly learn decision boundaries.
  • Simple pattern recognition tasks where speed and simplicity matter.
  • Basis for teaching and foundational understanding of neural networks.

What does it help to find?

  • It helps to estimate resource needs (time and memory) for perceptron training.
  • Helps to understand the linearly separable nature of data , crucial for perceptron success.
  • Aids in recognizing the limitations of the perceptron model in solving real-world nonlinear problems.

What and how does it help in real-world situations?

  • It highlights perceptron's strengths and weaknesses in practical machine learning problems.
  • Helps practitioners diagnose why training may not converge or why performance is limited.
  • Suggest when to scale features properly to improve convergence efficiency.
  • Informs the transition to more sophisticated models (e.g., MLPs, SVMs) when perceptron struggles.

Quick Teacherโ€™s Explanation

The perceptron learning complexity depends on data size, features, and how well data is separated. It works efficiently for linearly separable data but struggles otherwise. Its training time can grow large for complex data, and it doesnโ€™t provide probabilities or handle imbalanced classes well. Because it models only linear boundaries with no hidden layers, itโ€™s limited in real-world use. Knowing these limits helps decide when to use perceptrons and when to switch to advanced neural networks.

Simple Example Illustrating Complexity and Limits

Suppose you have 1000 data points (n=1000), each with 20 features (d=20). The perceptron trains in ๐‘‡ iterations, which depends on data separability.

  • Time per iteration: ๐‘‚(๐‘› โ‹… ๐‘‘) = 1000 ร— 20 = 20 , 000 operations.
  • If ๐‘‡ = 50 (number of iterations to converge), total operations = 20 , 000 ร— 50 = 1 , 000 , 000. If data is not linearly separable, ๐‘‡ grows indefinitely, and the perceptron never converges.

Linearly Separable Functions and Learning XOR-

Feed Forward Networks

What does the topic say/What is the topic?

This topic discusses two main ideas:

  • Linearly Separable Functions : Functions or datasets where classes can be separated perfectly by a straight line (in 2D), plane (in 3D), or hyperplane (in higher dimensions). Such data is said to be linearly separable.
  1. Backpropagate error to calculate gradients of weights.
  2. Update weights using gradient descent.
  3. Repeat steps 2-5 until the network learns XOR correctly.

How does the topic help?

  • Understanding linear separability helps identify if a simple linear classifier is sufficient for a problem or if more complex models are needed.
  • Using feed-forward networks with hidden layers enables learning of complex, non-linear functions like XOR.
  • Shows how adding hidden layers and non-linear activations lets neural networks model complex patterns that single-layer models cannot.

Applications

  • Linearly Separable Functions : Basic classification tasks like spam filtering or simple image recognition where classes can be linearly divided.
  • Feed-forward Networks for XOR and beyond : Tasks requiring capturing complex patterns like image classification, speech recognition, and natural language processing where data is often non- linear.

What does it help to find?

  • Helps find whether data can be classified using a linear boundary or requires non-linear models.
  • In feed-forward networks, it helps find complex decision boundaries by transforming inputs through hidden layers.
  • Supports finding optimal network parameters such as weights and biases via backpropagation to minimize classification errors.

What and how does it help in real-world situations?

  • Identifies when simple models like perceptrons will fail and when to use deeper, feed-forward networks.
  • Enables solutions for complex classification problems, like medical diagnosis, that are not linearly separable.
  • Allows for automatic feature extraction and decision-making in multi-dimensional, nonlinear data spaces.
  • Provides the foundation for modern deep learning models used in advanced AI applications.

Quick Teacherโ€™s Explanation

Some problems can be separated perfectly by a straight line โ€” these are called linearly separable. Simple perceptrons work well here. But others, like the XOR problem, have outputs that can't be split by a single line. To solve XOR, you use a feed-forward neural network with hidden layers that combine inputs in complex ways. These multi-layer networks learn non-linear boundaries by adjusting weights through training. This concept shows why sometimes simple models are enough, and sometimes deep networks are necessary for accurate learning.

Simple Example: XOR Problem Learning with Feed-

Forward Network

XOR Truth Table: x1 x2 XOR(x1,x2) 0 0 0 0 1 1 1 0 1 1 1 0

  • Single-layer perceptron cannot find any line to separate the 1s and 0s.
  • A feed-forward network with two input neurons, two hidden neurons, and one output neuron uses sigmoid activations.
  • After multiple training iterations, the network learns weights that produce outputs close to XOR.

o The loss quantifies the difference between predicted and true outputs.

  1. Backward Pass (Gradient Computation): o Starting at the output layer, compute the derivative of the loss with respect to output activations. o Use the chain rule to propagate this error backward through the network, layer by layer: โ–ช Compute the gradient of loss w.r.t. weighted sums using the derivative of activation functions. โ–ช Calculate gradients for weights and biases.
  2. Parameter Update: o Update weights and biases using an optimization algorithm (usually gradient descent or its variants):๐‘ค๐‘›๐‘’๐‘ค = ๐‘ค๐‘œ๐‘™๐‘‘ โˆ’ ๐œ‚ ๐œ•๐ฟ ๐œ•๐‘ค where ๐œ‚ is the learning rate and ๐œ•๐ฟ ๐œ•๐‘ค is the computed gradient.
  3. Iterative Process: o Repeat forward pass, loss computation, backward pass, and parameter updates for multiple epochs until the network converges to a solution minimizing the loss.

How does the topic help?

  • Enables efficient learning by precisely calculating how each parameter influences the final error.
  • Breaks down complex derivative calculations into manageable steps, making training of deep networks feasible.
  • Forms the backbone of deep learning , allowing networks with multiple layers to be trained effectively.
  • Supports the use of various activation functions and network architectures.

Applications

  • Training fully-connected MLPs for classification and regression tasks.
  • Foundational for complex models in image recognition, natural language processing , and speech recognition.
  • Used in autonomous systems for pattern recognition and decision-making.
  • Core part of training deep neural networks and convolutional neural networks (CNNs).

What does it help to find?

  • It helps find the optimal weights and biases minimizing the loss function.
  • Determines the direction and magnitude of parameter updates to improve the modelโ€™s performance.
  • Enables automatic differentiation of complex networks.

What and how does it help in real-world situations?

  • Makes training deep neural networks practical, enabling technologies like voice assistants, self- driving cars, and medical diagnosis tools.
  • Facilitates learning from large datasets with complex, hierarchical features.
  • Improves accuracy and generalization of machine learning models in diverse fields.

Quick Teacherโ€™s Explanation

Backpropagation is a method to teach neural networks by calculating how much each connection (weight) affects the final error. It uses the chain rule to break down gradients layer by layer, starting from the output back to inputs. With these gradients, network weights are updated to reduce errors gradually. This method allows deep, multi-layer networks to learn complex problems effectively through repeated forward and backward passes.

Simple Numerical Walkthrough (Example)

Suppose a simple MLP with one hidden neuron:

  • Input: ๐‘ฅ = [๐‘ฅ 1 , ๐‘ฅ 2 ] = [0.5, 0.6]
  • Weights to hidden neuron: ๐‘ค 1 = 0. 4 , ๐‘ค 2 = โˆ’ 0. 3 , bias ๐‘ 1 = 0. 1
  • Weights to output neuron: ๐‘ฃ = 0. 7 , bias ๐‘ 2 = โˆ’ 0. 2
  • Sigmoid activation function: ๐œŽ(๐‘ง) = 1 1 +๐‘’โˆ’๐‘ง
  • Target output ๐‘ก = 1 Step 1: Forward Pass
  • Hidden neuron sum:๐‘งโ„Ž = 0. 5 ร— 0. 4 + 0. 6 ร— (โˆ’ 0. 3 ) + 0. 1 = 0. 2 โˆ’ 0. 18 + 0. 1 = 0. 12
  • Hidden neuron activation:๐‘Žโ„Ž = ๐œŽ( 0. 12 ) โ‰ˆ 0. 53

= โˆ’ 0. 2 โˆ’ 0. 1 ร— (โˆ’ 0. 114 ) = โˆ’ 0. 1886

๐‘ค 1 ,๐‘›๐‘’๐‘ค = 0. 4 โˆ’ 0. 1 ร— (โˆ’ 0. 00985 ) = 0. 400985

๐‘ค 2 ,๐‘›๐‘’๐‘ค = โˆ’ 0. 3 โˆ’ 0. 1 ร— (โˆ’ 0. 0118 ) = โˆ’ 0. 29882

๐‘ 1 ,๐‘›๐‘’๐‘ค = 0. 1 โˆ’ 0. 1 ร— (โˆ’ 0. 0197 ) = 0. 102

Summary: weights and biases are adjusted slightly to minimize the loss on this example. Repeating this over many examples trains the network.

PYPS

{4 MARKER}

14.explain the working of a single layer perceptron. mention one limitation of this model

  1. apply linearly separable patterns in the context of neural networks.give one example of a linearly separable logic gate
  2. explain the purpose of the backpropagation algorithm in neural networks. mention one advantage of using it. {8 MARKERS} 18.a illustrate the architecture and functioning of single layer feedforward perceptron. describe its learning rule with appropriate diagram, and demonstrate how it can be used to implement basic logic gates 18.b illustrate the perceptron learning rule. discuss its algorithm, weight update mechanism and conditions for convergence 22 a.Analyze the need for Back Propagation Algorithm. How can we perfonn Back- Propagation Computation in Fully-Connected Multi-layer Perceptron. Explain the step by step process ofBack propagation algorithm in detail 22.b. Analyze the process in which Single Neuron Perceptron is following the perceptron architecture model. Provide step by step execution of Single Neuron Perceptron with numerical example in detail Here are the answers to your Unit 2 questions as per your requested detailed format:

14. Explain the Working of a Single-Layer Perceptron. Mention One Limitation of this

Model

What does the topic say / What is the topic? A single-layer perceptron is a basic artificial neural network model consisting of one layer of output nodes fully connected to the input features. It is a simple binary classifier that decides whether an input belongs to a particular class based on a linear boundary.[58][59] How does it work?

  • Each input feature is multiplied by a corresponding weight indicating its importance.
  • These weighted inputs are summed with a bias to produce a net input: ๐‘ง = โˆ‘๐‘ค๐‘–๐‘ฅ๐‘– + ๐‘.
  • This net input passes through an activation function, usually a step (Heaviside) function, that outputs 1 if ๐‘ง โ‰ฅ 0 and 0 otherwise.
  • Based on this, the perceptron classifies input into two classes (binary classification).
  • During training, weights and bias are updated iteratively to minimize the classification error using the perceptron learning rule. Limitation
  • It can only classify linearly separable data. For non-linear problems like XOR, it fails to find a decision boundary.[59][60][58] How does the topic help?
  • Provides a fundamental understanding of linear classifiers and network training basics. Applications
  • Simple binary classification tasks like spam detection, basic pattern recognition. What does it help to find?
  • Understanding linear separability and simple decision boundaries. What and how does it help in real-world situations?
  • Useful for straightforward classification problems with clearly separable data. Quick Teacherโ€™s Explanation The single-layer perceptron adds up inputs times weights, checks if the total crosses a threshold, and