Activation Functions
Activation Functions
Grade: AA / AB / BB / BC / CC / CD /DD
Theoretical Background:
The Neural Networks have been inspired by the goal of modeling biological neural systems and
are increasingly achieving good results in Machine Learning tasks. The basic computational unit
of the brain is a neuron. Approximately 86 billion neurons can be found in the human nervous
system and are connected with approximately 1014 – 1015 synapses. The diagram below shows a
simplified drawing of a biological neuron (left) and a common mathematical model (right). Each
neuron receives input signals from its dendrites and produces output signal along its axon. The
axon eventually branches out and connects via synapses to dendrites of other neurons. In the
computational model of a neuron, the signals that travel along the axons (e.g. x0) interact
multiplicatively (e.g. w0x0) with the dendrites of the other neuron based on the synaptic strength
at that synapse (e.g. w0). The idea is that the synaptic strengths (the weights w) are learnable and
control the strength of influence (and its direction: excitatory –(positive weight) or inhibitory
(negative weight)) of one neuron on another. In the basic model, the dendrites carry the signal to
the cell body where they all get summed. If the final sum is above a certain threshold, the neuron
can fire, sending a spike along its axon. In the computational model, we model the firing of the
neuron with an activation function, f.
f xi f xi 1 f x x for i j
x j f xi f x j for i j
Observations: 1) Execute python code to observe the characteristic plot of the above
activation functions and plot them below.
Binary Rectified
Step Linear Unit
(ReLU)
Sigmoid Bipolar
Sigmoid
3) Following figure shows a two layer neural network consisting of one hidden layer and
one output layer. Two activation functions, S= Bipolar Sigmoid, and L= Identity, can be
implemented for the
three neurons\nodes in the network.
4) State the desirable properties of activation functions used in neural networks. (you mad add more
rows if required)
Sr. Desirable property
No.
1. Non -linearity
1.1. Complex mapping of input - output
2. Differentiable (continuously)
2.1. Requirement for backpropagation algorithm
2.1.1. It requires computation of the gradient of the activation function at each iteration step
2.2. We should be able to find slope of the curve at any two points
3. Monotonic and Continuous
3.1. Should be a function which is either entirely non-increasing or non-decreasing
3.1.1. Ensures that gradients/derivatives do not vanish(zero)
5) For the following network consisting of a single neuron, two inputs and one output, write a
Python code to find output considering the various activation functions you have studied above.
Assume some relevant values for x1, x2, w1 and w2.
w1 yin
x1
yout
x2
w2
Conclusion:
In artificial neurons, inputs and weights are given from which the weighted sum of input is
calculated, and then it is given to an activation function that converts it into the output. So basically
an activation function is used to map the input to the output. This activation function helps a neural
network to learn complex relationships and patterns in data. One important use of the activation
function is to keep output restricted to a particular range. Another use of activation function is to add
non-linearity in data. Most of the time for hidden layers ReLU and its variants are used and for the
final layer, softmax or linear function is used depending upon the type of problem.