Artifical Intelegent (Print)
Artifical Intelegent (Print)
2. Plateau: A plateau is the flat area of the search space in which all the neighbor
states of the current state contains the same value, because of this algorithm
does not find any best direction to move. A hill-climbing search might be lost in
the plateau area.
Ridge
The hill-climbing algorithm may terminate itself when it reaches a ridge. This is
because the peak of the ridge is followed by downward movement rather than
upward movement.
2. Deterministic vs Stochastic:
If an agent's current state and selected action can completely determine the next
state of the environment, then such environment is called a deterministic
environment.
A stochastic environment is random in nature and cannot be determined
completely by an agent.
In a deterministic, fully observable environment, agent does not need to worry
about uncertainty.
Examples:
Chess – there would be only a few possible moves for a coin at the current state
and these moves can be determined.
Self-Driving Cars- the actions of a self-driving car are not unique, it varies time
to time.
. Competitive vs Collaborative
An agent is said to be in a competitive environment when it competes against
another agent to optimize the output.
The game of chess is competitive as the agents compete with each other to win
the game which is the output.
An agent is said to be in a collaborative environment when multiple agents
cooperate to produce the desired output.
When multiple self-driving cars are found on the roads, they cooperate with
each other to avoid collisions and reach their destination which is the output
desired.
Single-agent vs Multi-agent
An environment consisting of only one agent is said to be a single-agent
environment.
A person left alone in a maze is an example of the single-agent system.
An environment involving more than one agent is a multi-agent environment.
The game of football is multi-agent as it involves 11 players in each team.
Known vs Unknown
In a known environment, the output for all probable actions is given.
Obviously, in case of unknown environment, for an agent to make a decision, it
has to gain knowledge about how the environment works.
Episodic vs Sequential
In an Episodic task environment, each of the agent’s actions is divided into
atomic incidents or episodes. There is no dependency between current and
previous incidents. In each incident, an agent receives input from the
environment and then performs the corresponding action.
Example: Consider an example of Pick and Place robot, which is used to detect
defective parts from the conveyor belts. Here, every time robot(agent) will
make the decision on the current part i.e. there is no dependency between
current and previous decisions.
In a Sequential environment, the previous decisions can affect all future
decisions. The next action of the agent depends on what action he has taken
previously and what action he is supposed to take in the future.
Example:
Checkers- Where the previous move can affect all the following moves.
What is cryptarithmetic ?
A cryptarithmetic puzzle is a mathematical exercise where the digits of some
numbers are represented by letters (or symbols). Each letter represents a unique
digit.
SEND 9567
MORE 1085
-------------- -------------------
MONEY 10652
Allele: Allele is the value provided to the gene within a particular chromosome.
Selection
After calculating the fitness of every existent in the population, a selection
process is used to determine which of the individualities in the population will
get to reproduce and produce the seed that will form the coming generation.
Initial Population
The process begins with a set of individuals which is called a Population. Each
individual is a solution to the problem you want to solve.
An individual is characterized by a set of parameters (variables) known as Genes.
Genes are joined into a string to form a Chromosome (solution).
In a genetic algorithm, the set of genes of an individual is represented using a string,
in terms of an alphabet. Usually, binary values are used (string of 1s and 0s). We say
that we encode the genes in a chromosome.
Fitness Function
The fitness function determines how fit an individual is (the ability of an individual to
compete with other individuals). It gives a fitness score to each individual. The
probability that an individual will be selected for reproduction is based on its fitness
score.
Selection
The idea of selection phase is to select the fittest individuals and let them pass their
genes to the next generation.
Two pairs of individuals (parents) are selected based on their fitness scores.
Individuals with high fitness have more chance to be selected for reproduction.
Crossover
Crossover is the most significant phase in a genetic algorithm. For each pair of
parents to be mated, a crossover point is chosen at random from within the genes.
For example, consider the crossover point to be 3 as shown below.
Mutation
The mutation operator inserts random genes in the offspring (new child) to
maintain the diversity in
the population. It can be
done by flipping some
bits in the
chromosomes.
Termination
The algorithm terminates after the threshold fitness solution is reached. It will
identify the final solution as the best solution in the population.
What is DENDRAL ?
The software program Dendral is considered the first expert system because it
automated the decision-making process and problem-solving behavior of organic
chemists.
In a human expert we
deal with human brain
in which knowledge
exists in a compiled It provide a clear separation of
form. knowledge from its processing.
Human experts Expert System
It uses inexact
reasoning and also
able to deal with It permits inexact reasoning and
incomplete, uncertain but able to deal with incomplete,
and fuzzy information. uncertain and fuzzy data.
Importance of AI
AI technology is important because it enables human capabilities – understanding,
reasoning, planning, communication and perception – to be undertaken by
software increasingly effectively, efficiently and at low cost.
Describe the concept of Hebbian learning.
What is synapse ?
A synapse is the connection between nodes, or neurons, in an
artificial neural network (ANN). Similar to biological brains, the
connection is controlled by the strength or amplitude of a connection
between both nodes, also called the synaptic weight. Multiple synapses
can connect the same neurons, with each synapse having a different
level of influence (trigger) on whether that neuron is “fired” and
activates the next neuron.
Dendrites-input
Synapse – weight
Axon-output
Artificial Neural Network primarily consists of three layers:
neural network that consists of a large number of artificial neurons, which are
termed units arranged in a sequence of layers. Lets us look at various types of
layers available in an artificial neural network.
Input Layer:
As the name suggests, it accepts inputs in several different formats provided by
the programmer.
Hidden Layer:
The hidden layer presents in-between input and output layers. It performs all
the calculations to find hidden features and patterns.
Output Layer:
The input goes through a series of transformations using the hidden layer, which
finally results in output that is conveyed using this layer.
The structure of an
artificial neuron is
very similar to a
biological neuron, it
consists of 3 main
parts, weight and bias
as a dendrite denoted
by w and b
respectively, output
as an axon denoted
by y, and activation
function as a cell
body (nucleus) denoted by f(x). The x is the input signals received by the
dendrite.
What is an activation function and why use them?
The activation function decides whether a neuron should be activated
or not by calculating the weighted sum and further adding bias to it.
Explanation: We know, the neural network has neurons that work in
correspondence with weight, bias (bias can be defined as the constant which
is added to the product of features and weights. It is used to offset the
result. It helps the models to shift the activation function towards the positive
or negative side.), and their respective activation function. In a neural network,
we would update the weights and biases of the neurons on the basis of the error
at the output. This process is known as back-propagation. Activation
functions make the back-propagation possible since the gradients ( A gradient
simply measures the change in all weights with regard to the change in
error.) are supplied along with the error to update the weights and biases.
Hebbian learning
Hebbian Learning Rule, also known as Hebb Learning Rule, was proposed by
Donald O Hebb. It is one of the first and also easiest learning rules in the neural
network. It a mechanism to update weights between neurons in a neural
network. This method of weight updation enabled neurons to learn new things .
The basis of the theory is when our brains learn something new, neurons are
activated and connected with other neurons, forming a neural network. These
connections start off weak, but each time the stimulus is repeated, the
connections grow stronger and stronger, and the action becomes more intuitive.
A good example is the act of learning to drive. When you start out, everything
you do is incredibly deliberate. You remind yourself to turn on your indicator, to
check your blind spot, and so on. However, after years of experience, these
processes become so automatic that you perform them without even thinking.
If two neighbor neurons activated and deactivated at the same time. Then the
weight connecting these neurons should increase. For neurons operating in the
opposite phase, the weight between them should decrease. If there is no signal
correlation, the weight should not change.
When inputs of both the nodes are either positive or negative, then a strong
positive weight exists between the nodes. If the input of a node is positive and
negative for other, a strong negative weight exists between the nodes.
At the start, values of all weights are set to zero.
Hebbian learning is a single layer neural network, i.e. it has one input layer and
one output layer. The input layer can have many units, say n. The output layer
only has one unit. Hebbian rule works by updating the weights between neurons
in the neural network for each training sample.
The steps 2 to 4 are repeated for each input vector and output.
Turing Test
In 1950, Alan Turing introduced a test to check whether a machine can think like
a human or not, this test is known as the Turing Test. In this test, Turing
proposed that the computer can be said to be an intelligent if it can mimic
human response under specific conditions. Turing Test was introduced by
Turing in his 1950 paper, "Computing Machinery and Intelligence," which
considered the question, "Can Machine think?"
The Turing test is based on a party
game "Imitation game," with some
modifications. This game involves
three players in which one player is
Computer, another player is human
responder, and the third player is a
human Interrogator, who is isolated
from other two players and his job
is to find that which player is
machine among two of them.
Consider, Player A is a computer, Player B is human, and Player C is an
interrogator. Interrogator is aware that one of them is machine, but he needs to
identify this on the basis of questions and their responses.
The conversation between all players is via keyboard and screen so the result
would not depend on the machine's ability to convert words as speech.
The test result does not depend on each correct answer, but only how closely its
responses like a human answer. The computer is permitted to do everything
possible to force a wrong identification by the interrogator.
The questions and answers can be like:
Interrogator: Are you a computer?
PlayerA (Computer): No
Interrogator: Multiply two large numbers such as (256896489*456725896)
Player A: Long pause and give the wrong answer.
In this game, if an interrogator would not be able to identify which is a machine
and which is human, then the computer passes the test successfully, and the
machine is said to be intelligent and can think like a human.
Acting humanly
To be considered intelligent a program must be able to act sufficiently like a
human to fool an interrogator.
1 if X >T
If Y=F(X)= 0 if X<T
Bias / threshold : minimum valu of weighted active input for a neuron to fire .
McCulloch-Pitts model neuron (i) with three inputs (dendrites) and one output
(axon). Each synapse (junction) has a weight: w i1 , w i2 , w i3. The neuron
receives information as the weighted sum
(x=∑{L1W1+L2W2+L3W3+…+LnWn})of the three inputs (L1 ,L2 ,L3 ), which in
turn is passed through a discontinuous threshold sigmoid non-linearly to obtain
a new activation (new input) value, denoted by y = f (x) = f
(∑{L1W1+L2W2+L3W3+……….+LnWn })
AND Function
Minimax algorithm
• Minimax is a kind of backtracking algorithm that is used in decision
making and game theory to find the optimal move for a player, assuming
that your opponent also plays optimally. It is widely used in two player
turn-based games such as Tic-Tac-Toe, Backgammon, Mancala, Chess, etc.
• In Minimax the two players are called maximizer and minimizer.
The maximizer tries to get the highest score (utility) possible while
the minimizer tries to do the opposite and get the lowest score possible.
• The minimax algorithm performs a depth-first search algorithm for the
exploration of the complete game tree.
• The minimax algorithm proceeds all the way down to the terminal node
of the tree, then backtrack the tree max will choose best move.
Example:
Consider a game which has 4 final states and paths to reach final state are from
root to 4 leaves of a perfect binary tree as shown below. Assume you are the
maximizing player and you get the first chance to move, i.e., you are at the root
and your opponent at next level. Which move you would make as a
maximizing player considering that your opponent also plays optimally?
B returns 5 to A. At A,
alpha = max( -INF, 5)
which is 5. Now the
maximizer is
guaranteed a value of 5
or greater. A now
calls C to see if it can
get a higher value than
5.
At C, alpha = 5 and beta = +INF. C calls F
At F, alpha = 5 and beta = +INF. F looks at its left child which is a 1. alpha = max( 5,
1) which is still 5.
F looks at its right child which is a 2. Hence the best value of this node is 2. Alpha
still remains 5
F returns a value of 2 to C. At C, beta = min( +INF, 2). The condition beta <= alpha
becomes true as beta = 2 and alpha = 5. So it breaks and it does not even have to
compute the entire sub-tree of G.
The intuition behind this break-off is that, at C the minimizer was guaranteed a
value of 2 or lesser. But the maximizer was already guaranteed a value of 5 if he
choose B. So why would the maximizer ever choose C and get a value less than 2 ?
Again you can see that it did not matter what those last 2 values were. We also
saved a lot of computation by skipping a whole sub-tree.
C now returns a value of 2 to A. Therefore the best value at A is max( 5, 2) which is
a 5.
Hence the optimal value that the maximizer can get is 5
This is how our final game tree looks like. As you can see G has been crossed out as
it was never computed.
Agents
An agent can be anything that perceiveits environment through sensors and act
upon that environment through actuators. An Agent runs in the cycle
of perceiving, thinking, and acting.
A (rational)agent could be anything that makes decisions, as a person, firm,
machine, or software. It carries out an action with the best outcome after
considering past and current percepts(agent’s perceptual inputs at a given
instance). An AI system is composed of an agent and its environment. The agents
act in their environment. The environment may contain other agents.
An agent is anything that can be viewed as :
perceiving its environment through sensors and
acting upon that environment through actuators
Note: Every agent can perceive its own actions (but not always the effects)
intelligent agent
An intelligent agent is an autonomous entity which act upon an environment
using sensors and actuators for achieving goals.
intelligent agents may learn from the environment to achieve those goals.
Driverless cars and the Siri virtual assistant are examples of intelligent agents in
AI. A thermostat is an example of an intelligent agent.
Following are the main four rules for an AI agent:
Rule 1: An AI agent must have the ability to perceive the environment.
Rule 2: The observation must be used to make decisions.
Rule 3: Decision should result in an action.
Rule 4: The action taken by an AI agent must be a rational action.
Ration agent
A rational agent could be anything that makes decisions, as a person, firm,
machine, or software. It carries out an action with the best outcome after
considering past and current percepts(agent's perceptual inputs at a given
instance).
Perform optimal actions based on given premises and information.
For example, consider the case of this Vacuum cleaner as a Rational agent. It has
the environment as the floor which it is trying to clean. It has sensors like Camera’s
or dirt sensors which try to sense the environment. It has the brushes and the
suction pumps as actuators which take action. Percept is the agent’s perceptual
inputs at any given point of time. The action that the agent takes on the basis of the
perceptual input is defined by the agent function.
Hence before an agent is put into the environment, a Percept sequence and the
corresponding actions are fed into the agent. This allows it to take action on the
basis of the inputs.
An example would be something like a table
Percept Sequence Action
Rational Agent: The rational agent evaluates all options and selects the most
efficient action. For example, it selects the shortest road with the lowest cost for
maximum efficiency. PEAS is a term that stands for Performance
Measure, Environment, Actuator, and Sensor.
Performance Measure: Performance measure is the unit used to define an
agent’s success. The performance of agents changes according to their distinct
principles.
Environment: The environment is an agent’s immediate surroundings. If the
agent is set in motion, it changes over time. There are five primary types of
environments:
Fully Observable & Partially Observable
Episodic & Sequential
Static & Dynamic
Discrete & Continuous
Deterministic & Stochastic
Actuator: An actuator is a component of the agent that provides the action’s
output to the environment.
Sensor: Sensors are the receptive components of an agent that receive input.
FIFO (Queue)
AB
BCD
CDGH
DGHEF
GHEF
HEFI
EFI
FIK
IK
The heuristic function (rule of thumb) is a way to inform the search about the
direction to a goal. It provides an informed way to guess which neighbor of a
node will lead to a goal. Heuristic is a function which is used in Informed Search,
and it finds the most promising path. It takes the current state of the agent as its
input and produces the estimation of how close agent is from the goal. The
heuristic method, however, might not always give the best solution, but it
guaranteed to find a good solution in reasonable time. Heuristic function
estimates how close a state is to the goal.
It is a technique designed to solve a problem quickely.
Every state ko cost /time dinxa heuristic la
Heuristic is kind a note ko value jasti ho
Example:
Consider the below search problem, and we will traverse it using greedy best-
first search. At each iteration, each node is expanded using evaluation
function f(n)=h(n) , which is given in the below table.
In this search example, we are
using two lists which
are OPEN and CLOSED Lists.
Following are the iteration for
traversing the above example.
A* Search Algorithm:
A* search is the most commonly known form of best-first search. It uses
heuristic function h(n), and cost to reach the node n from the start state g(n)..
A* search algorithm finds the shortest path through the search space using
the heuristic function. This search algorithm expands less search tree and
provides optimal result faster.
In A* search algorithm, we use search heuristic as well as the cost to reach the node.
Hence we can combine both costs as following, and this sum is called as a fitness
number.
Advantages:
A* search algorithm is the best algorithm than other search algorithms.
A* search algorithm is optimal and complete.
This algorithm can solve very complex problems.
Disadvantages:
It does not always produce the shortest path as it mostly based on heuristics and
approximation.
A* search algorithm has some complexity issues.
The main drawback of A* is memory requirement as it keeps all generated nodes in
the memory, so it is not practical for various large-scale problems.
Example:
In this example, we will traverse the given graph using the A* algorithm. The
heuristic value of all states is given in the below table so we will calculate the
f(n) of each state using the formula f(n)= g(n) + h(n), where g(n) is the cost to
reach any node from start state.
Here we will use OPEN and CLOSED list.
Solution:
Using It uses knowledge for the searching It doesn’t use knowledge for
Knowledge process. the searching process.
Size of search Having a wide scope in terms of Solving a massive search task
problems handling large search problems. is challenging.
Parameters Informed Search Uninformed Search
Propositional logic (PL) is the simplest form of logic where all the statements
are made by propositions. A proposition is a declarative statement which is
either true or false. It is a technique of knowledge representation in logical
and mathematical form.
Example:
a) It is Sunday.
b) The Sun rises from West (False proposition)
c) 3+3= 7(False proposition)
d) 5 is a prime number.
Following are some basic facts about propositional logic:
Propositional logic is also called Boolean logic as it works on 0 and 1.
In propositional logic, we use symbolic variables to represent the logic, and we can
use any symbol for a representing a proposition, such A, B, C, P, Q, R, etc.
Propositions can be either true or false, but it cannot be both.
Propositional logic consists of an object, relations or function, and logical
connectives.
These connectives are also called logical operators.
The propositions and connectives are the basic elements of the propositional logic.
Connectives can be said as a logical operator which connects two sentences.
A proposition formula which is always true is called tautology, and it is also called a
valid sentence.
A proposition formula which is always false is called Contradiction.
A proposition formula which has both true and false values is called
Statements which are questions, commands, or opinions are not propositions such
as "Where is Rohini", "How are you", "What is your name", are not propositions.
Syntax of propositional logic:
The syntax of propositional logic defines the allowable sentences for the knowledge
representation. There are two types of Propositions:
Atomic Propositions
Compound propositions
Atomic Proposition: Atomic propositions are the simple propositions. It consists of a
single proposition symbol. These are the sentences which must be either true or
false.
Example:
a) 2+2 is 4, it is an atomic proposition as it is a true fact.
b) "The Sun is cold" is also a proposition as it is a false fact.
Compound proposition: Compound propositions are constructed by combining
simpler or atomic propositions, using parenthesis and logical connectives.
Example:
Precedence of connectives:
Just like arithmetic operators, there is a precedence order for propositional
connectors or logical operators. This order should be followed while evaluating a
propositional problem. Following is the list of the precedence order for operators:
Precedence Operators
Inference:
In artificial intelligence, we need intelligent computers which can create new
logic from old logic or by evidence, so generating the conclusions from
evidence and facts is termed as Inference.
Inference rules:
Inference rules are the templates for generating valid arguments. Inference rules are
applied to derive proofs in artificial intelligence, and the proof is a sequence of the
conclusion that leads to the desired goal.
In inference rules, the implication among all the connectives plays an important role.
Following are some terminologies related to inference rules:
Implication: It is one of the logical connectives which can be represented as P → Q.
It is a Boolean expression.
Converse: The converse of implication, which means the right-hand side proposition
goes to the left-hand side and vice-versa. It can be written as Q → P.
Contrapositive: The negation of converse is termed as contrapositive, and it can be
represented as ¬ Q → ¬ P.
Inverse: The negation of implication is called inverse. It can be represented as ¬ P →
¬ Q.
From the above term some of the compound statements are equivalent to each
other, which we can prove using truth table:
Hence from the above truth table, we can prove that P → Q is equivalent to ¬ Q → ¬
P, and Q→ P is equivalent to ¬ P → ¬ Q.
Types of Inference rules:
1. Modus Ponens:
The Modus Ponens rule is one of the most important rules of inference, and it states
that if P and P → Q is true, then we can infer that Q will be true. It can be
represented as:
Example:
Statement-1: "If I am sleepy then I go to bed" ==> P→ Q
Statement-2: "I am sleepy" ==> P
Conclusion: "I go to bed." ==> Q.
Hence, we can say that, if P→ Q is true and P is true then Q will be true.
Proof by Truth table:
2. Modus Tollens:
The Modus Tollens rule state that if P→ Q is true and ¬ Q is true, then ¬ P will also
true. It can be represented as:
4. Disjunctive Syllogism:
The Disjunctive syllogism rule state that if P∨Q is true, and ¬P is true, then Q will be
true. It can be represented as:
Example:
Statement-1: Today is Sunday or Monday. ==>P∨Q
Statement-2: Today is not Sunday. ==> ¬P
Conclusion: Today is Monday. ==> Q
Proof by truth-table:
5. Addition:
The Addition rule is one the common inference rule, and it states that If P is true,
then P∨Q will be true.
Example:
Statement: I have a vanilla ice-cream. ==> P
Statement-2: I have Chocolate ice-cream.
Conclusion: I have vanilla or chocolate ice-cream. ==> (P∨Q)
Proof by Truth-Table:
6. Simplification:
The simplification rule state that if P∧ Q is true, then Q or P will also be true. It can
be represented as:
Proof by Truth-Table:
7. Resolution:
The Resolution rule state that if P∨Q and ¬ P∧R is true, then Q∨R will also be true. It
can be represented as
Proof by Truth-Table:
Quantifiers
Quantifiers are the words that refer to quantities such as “ some ” or “all”
It tells for how many elements a given predicate is true.
IN ENGLISH
Quantifiers are used to express the quantities without giving an exact number .
Example : all, some , many etc
Universal Quantifier
Universal quantifier states that the statements within its scope are true for
every value of the specific variable. It is denoted by the symbol ∀∀.
∀xP(x)∀xP(x) is read as for every value of x, P(x) is true.
Example − "Man is mortal" can be transformed into the propositional
form ∀xP(x)∀xP(x) where P(x) is the predicate which denotes x is mortal
and the universe of discourse is all men.
Existential Quantifier
Existential quantifier states that the statements within its scope are true for
some values of the specific variable. It is denoted by the symbol ∃∃.
∃xP(x)∃xP(x) is read as for some values of x, P(x) is true.
Example − "Some people are dishonest" can be transformed into the
propositional form ∃xP(x)∃xP(x) where P(x) is the predicate which denotes
x is dishonest and the universe of discourse is some people.
User interface
With the help of a user
interface, the expert system
interacts with the user, takes
queries as an input in a
readable format, and passes
it to the inference engine.
After getting the response
from the inference engine, it
displays the output to the
user. In other words, it is an
interface that helps a non-expert user to communicate with the expert system to
find a solution.
2. Inference Engine(Rules of Engine)
The inference engine is known as the brain of the expert system as it is the main
processing unit of the system. It applies inference rules to the knowledge base to
derive a conclusion or deduce new information. It helps in deriving an error-free
solution of queries asked by the user.
With the help of an inference engine, the system extracts the knowledge from the
knowledge base.
3. Knowledge Base
The knowledgebase is a type of storage that stores knowledge acquired from the
different experts of the particular domain. It is considered as big storage of
knowledge. The more the knowledge base, the more precise will be the Expert
System.
It is similar to a database that contains information and rules of a particular domain
or subject.
One can also view the knowledge base as collections of objects and their attributes.
Such as a Lion is an object and its attributes are it is a mammal, it is not a domestic
animal, etc.
NPL
Natural language processing (NLP) refers to the branch of computer
science—and more specifically, the branch of artificial intelligence or AI—
concerned with giving computers the ability to understand text and spoken
words in much the same way human beings can.
Fig 1
In simple term , it calculates a “weighted sum(Wi)” of its input(xi), adds a bias
and then decides whether it should be “fired” or not.
Explanation of above figure (Fig 1),
All the input Xi’s are multiplied with their weight Wi’s assigned to each link and
summed together along with Bias b .
Note : Xi’s and Wi’s are vectors and b is scalar.
Let Y be summation of ( (Wi*Xi) + b )
The value of Y can be anything ranging from -inf to +inf. Meaning it has lot of
information ,now neuron must know to distinguish between the “useful” and “not
-so-useful” information.To build this sense into our network we add ‘activation
function (f)’— Which will decide whether the information passed is useful or not
based on the result it get fired.
Working of single layer network
Properties that Activation function should hold?
Derivative or Differential: Change in y-axis w.r.t. change in x-axis.It is also known as
slope.(Back prop)
Monotonic function: A function which is either entirely non-increasing or non-
decreasing.
Activation function Types :
Linear function
Binary Step function
Non-Linear function
Linear Function :
Linear function
A linear activation function takes the form:
y=mx+c ( m is line equation represents W and c is represented as b in neural nets so
equation can be modified as y=Wx+b)
It takes the inputs (Xi’s), multiplied by the weights(Wi’s) for each neuron, and
creates an output proportional to the input. In simple term, weighted sum input
is proportional to output.
As mentioned above , activation function should hold some properties with fails
in linear function.
Problem with Linear function,
1 ) Differential result is constant.
2) All layers of the neural network collapse into one.
Binary step function are popular known as “ Threshold function”. It is very simple
function.
The “softmax” function is also a type of sigmoid function but it is very useful to
handle multi-class classification problems.
“Softmax can be described as the combination of multiple sigmoidal function.”
“Softmax function returns the probability for a datapoint belonging to each
individual class.”
While building a network for a multiclass problem, the output layer would have
as many neurons as the number of classes in the target.
For instance if you have three classes[A,B,C], there would be three neurons in the
output layer. Suppose you got the output from the neurons as [2.2 , 4.9 ,
1.75].Applying the softmax function over these values, you will get the following
result — [0.52 , 0.21, 0.27]. These represent the probability for the data point
belonging to each class. From result we can that the input belong to class A.
“Note that the sum of all the values is 1.”
Which one is better to use ? How to choose a right one?
To be honest there is no hard and fast rule to choose the activation function.We
can’t differentiate between activation function.Each activation function as its own
pro’s and con’s.All the good and bad will be decided based on the trail.
But based on the properties of the problem we might able to make a better choice
for easy and quicker convergence of the network.
Sigmoid functions and their combinations generally work better in the case of
classification problems
Sigmoids and tanh functions are sometimes avoided due to the vanishing
gradient problem
ReLU activation function is widely used in modern era.
In case of dead neurons in our networks due to ReLu then leaky ReLU function is
the best choice
ReLU function should only be used in the hidden layers
“As a rule of thumb, one can begin with using ReLU function and then move over to
other activation functions in case ReLU doesn’t provide with optimum results”
What is an Agent?(2017)
An agent can be anything that perceiveits environment through sensors and act
upon that environment through actuators. An Agent runs in the cycle
of perceiving, thinking, and acting. An agent can be:
Human-Agent: A human agent has eyes, ears, and other organs which work for
sensors and hand, legs, vocal tract work for actuators.
Robotic Agent: A robotic agent can have cameras, infrared range finder, NLP for
sensors and various motors for actuators.
Software Agent: Software agent can have keystrokes, file contents as sensory
input and act on those inputs and display output on the screen.
Hence the world around us is full of agents such as thermostat, cellphone,
camera, and even we are also agents.
Sensor: Sensor is a device which detects the change in the environment and
sends the information to other electronic devices. An agent observes its
environment through sensors.
Actuators: Actuators are the component of machines that converts energy into
motion. The actuators are only responsible for moving and controlling a system.
An actuator can be an electric motor, gears, rails, etc.
Effectors: Effectors are the devices which affect the environment. Effectors can
be legs, wheels, arms, fingers, wings, fins, and display screen.
Types of AI Agents
Agents can be grouped into five classes based on their degree of perceived
intelligence and capability. All these agents can improve their performance and
generate better action over the time. These are given below:
Simple Reflex Agent
Model-based reflex agent
Goal-based agents
Utility-based agent
Learning agent
1. Simple Reflex agent:
The Simple reflex agents are the simplest agents. These agents take decisions on
the basis of the current percepts and ignore the rest of the percept history.
These agents only succeed in the fully observable environment.
The Simple reflex agent does not consider any part of percepts history during
their decision and action process.
The Simple reflex agent works on Condition-action rule, which means it maps
the current state to action. Such as a Room Cleaner agent, it works only if there is
dirt in the room.
Problems for the simple reflex agent design approach:
They have very limited intelligence
They do not have knowledge of non-perceptual parts of the current state
Mostly too big to generate and to store.
Not adaptive to changes in the environment.
2. Model-based
reflex agent
The Model-based
agent can work in a
partially observable
environment, and
track the situation.
A model-based agent
has two important
factors:
Model: It is
knowledge about
"how things happen
in the world," so it is called a Model-based agent.
Internal State: It is a representation of the current state based on percept history.
These agents have the model, "which is knowledge of the world" and based on
the model they perform actions.
Updating the agent state requires information about:
How the world evolves
How the agent's action affects the world.
3. Goal-based agents
The knowledge of the
current state environment
is not always sufficient to
decide for an agent to what
to do.
The agent needs to know
its goal which describes
desirable situations.
Goal-based agents expand
the capabilities of the
model-based agent by
having the "goal"
information.
They choose an action, so that they can achieve the goal.
These agents may have to consider a long sequence of possible actions before
deciding whether the goal is achieved or not. Such considerations of different
scenario are called
searching and
planning, which
makes an agent
proactive.
4. Utility-based
agents
These agents are
similar to the goal-
based agent but
provide an extra
component of utility
measurement which
makes them different
by providing a
measure of success at
a given state.
Utility-based agent act based not only goals but also the best way to achieve the
goal.
The Utility-based agent is useful when there are multiple possible alternatives,
and an agent has to choose in order to perform the best action.
The utility function maps each state to a real number to check how efficiently
each action achieves the goals.
5. Learning
Agents
A learning
agent in AI is
the type of
agent which
can learn from
its past
experiences,
or it has
learning
capabilities.
It starts to act
with basic
knowledge
and then able
to act and adapt automatically through learning.
A learning agent has mainly four conceptual components, which are:
Learning element: It is responsible for making improvements by learning from
environment
Critic: Learning element takes feedback from critic which describes that how
well the agent is doing with respect to a fixed performance standard.
Performance element: It is responsible for selecting external action
Problem generator: This component is responsible for suggesting actions that
will lead to new and informative experiences.
Hence, learning agents are able to learn, analyze performance, and look for new
ways to improve the performance.
McCulloch–Pitt neural
The McCulloch–Pitt neural network is considered to be the first neural network.
The neurons are connected by directed weighted paths. McCulloch–Pitt neuron
allows binary activation (1 ON or 0 OFF), i.e., it either fires with an activation 1
or does not fire with an activation of 0. If w > 0, then the connected path is said
to be excitatory else it is known as inhibitory. Excitatory connections have
positive weights and inhibitory connections have negative weights. Each neuron
has a fixed threshold for firing. That is, if the net input to the neuron is greater
than the threshold, it fires. Different Matlab Programs have been done to
generate output of various logical function using McCulloch-Pitt neural network
algorithm.
It may be divided into 2 parts. The first part, g takes an input (ahem dendrite
ahem), performs an aggregation and based on the aggregated value the second
part, f makes a decision.
Example: The problem is as follows: We have an agent and a reward, with many
hurdles in between. The agent is supposed to find the best possible path to reach the
reward. The following problem explains the problem more easily.
Positive –
Positive Reinforcement is defined as when an event, occurs due to a particular
behavior, increases the strength and the frequency of the behavior. In other
words, it has a positive effect on behavior.
Advantages of reinforcement learning are:
Maximizes Performance
Sustain Change for a long period of time
Too much Reinforcement can lead to an overload of states which can diminish
the results
Negative –
Negative Reinforcement is defined as strengthening of behavior because a
negative condition is stopped or avoided.
Advantages of reinforcement learning:
Increases Behavior
Provide defiance to a minimum standard of performance
It Only provides enough to meet up the minimum behavior
Now, the agent has successfully stored the previous steps assigning the 1
value to each previous block. But what will the agent do if he starts moving
from the block, which has 1 value block on both sides? Consider the below
diagram:
It will be a difficult
condition for the
agent whether he
should go up or
down as each block
has the same value.
So, the above
approach is not
suitable for the
agent to reach the
destination. Hence
to solve the
problem, we will
use the Bellman equation, which is the main concept behind reinforcement
learning.
Production systems
Production systems can be defined as a kind of cognitive (thinking)architecture,
in which knowledge is represented in the form of rules. So, a system that uses
this form of knowledge representation is called a production system. To simply
put, production systems consists of rules and factors. Knowledge is usually
encoded in a declarative from which comprises of a set of rules of the form.
The Major Components Of An AI Production System
A global database
A set of production rules
A control system
The global database is the central data structure which used by an AI production
system. The production system. The production rules operate on the global
database. Each rule usually has a precondition that is either satisfied or not by
the global database. If the precondition is satisfied, the rule is usually be applied.
Application of the rule changes the database. The control system then chooses
which applicable rule should be applied and ceases computation when a
termination condition on the database is satisfied. If multiple rules are to fire at
the same time, the control system resolves the conflicts.
4 Major Features Of Production System
Simplicity
Modularity
Modifiability
Knowledge Intensive
Components of Production System
The major components of the Production System in Artificial Intelligence are:
Global Database: The global database is the central data structure used by the
production system in Artificial Intelligence.
Set of Production Rules: The production rules operate on the global database. Each
rule usually has a precondition that is either satisfied or not by the global database. If
the precondition is satisfied, the rule is usually be applied. The application of the rule
changes the database.
Control system chooses which rule to apply.
(Forward)
Example:
"As per the law, it is a crime for an American to sell weapons to hostile nations.
Country A, an enemy of America, has some missiles, and all the missiles were sold
to it by Robert, who is an American citizen."
Prove that "Robert is criminal."
To solve the above problem, first, we will convert all the above facts into first-order
definite clauses, and then we will use a forward-chaining algorithm to reach the
goal.
Facts Conversion into FOL:
It is a crime for an American to sell weapons to hostile nations. (Let's say p, q, and r
are variables)
American (p) ∧ weapon(q) ∧ sells (p, q, r) ∧ hostile(r) → Criminal(p) ...(1)
Country A has some missiles. ?p Owns(A, p) ∧ Missile(p). It can be written in two
definite clauses by using Existential Instantiation, introducing new Constant T1.
Owns(A, T1) ......(2)
Missile(T1) .......(3)
All of the missiles were sold to country A by Robert.
?p Missiles(p) ∧ Owns (A, p) → Sells (Robert, p, A) ......(4)
Missiles are weapons.
Missile(p) → Weapons (p) .......(5)
Enemy of America is known as hostile.
Enemy(p, America) →Hostile(p) ........(6)
Country A is an enemy of America.
Enemy (A, America) .........(7)
Robert is American
American(Robert). ..........(8)
Step-2:
At the second step, we will see those facts which infer from available facts and with
satisfied premises.
Rule-(1) does not satisfy premises, so it will not be added in the first iteration.
Rule-(2) and (3) are already added.
Rule-(4) satisfy with the substitution {p/T1}, so Sells (Robert, T1, A) is added, which
infers from the conjunction of Rule (2) and (3).
Rule-(6) is satisfied with the substitution(p/A), so Hostile(A) is added and which
infers from Rule-(7).
Step-3:
At step-3, as we can check Rule-(1) is satisfied with the substitution {p/Robert, q/T1,
r/A}, so we can add Criminal(Robert) which infers all the available facts. And hence
we reached our goal statement.
Hence it is proved that Robert is Criminal using forward chaining approach.
Example:backward
In backward-chaining, we will use the same above example, and will rewrite all the rules.
Backward-Chaining proof:
In Backward chaining, we will start with our goal predicate, which is Criminal(Robert), and then
infer further rules.
Step-1:
At the first step, we will take the goal fact. And from the goal fact, we will infer other facts, and
at last, we will prove those facts true. So our goal fact is "Robert is Criminal," so following is the
predicate of it.
Step-2:
At the second step, we will infer other facts form goal fact which satisfies the rules. So as we can
see in Rule-1, the goal predicate Criminal (Robert) is present with substitution {Robert/P}. So we
will add all the conjunctive facts below the first level and will replace p with Robert.
Step-3:t At step-3, we will extract further fact Missile(q) which infer from Weapon(q), as it
satisfies Rule-(5). Weapon (q) is also true with the substitution of a constant T1 at q.
Step-4:
At step-4, we can infer facts Missile(T1) and Owns(A, T1) form Sells(Robert, T1, r) which satisfies
the Rule- 4, with the substitution of A in place of r. So these two statements are proved here.
Step-5:
At step-5, we can infer the fact Enemy(A, America) from Hostile(A) which satisfies Rule- 6. And
hence all the statements are proved true using backward chaining.