Example Problems - NN


Example-1:

Calculate the output of a 3-input neuron with X=[0,1.0,0.5], W=[0.9,0.2,0.3] and b= -0.04.Use sigmoid activation function.



Step 1: Calculate the weighted sum

The neuron first calculates:

z=∑i=13wixi+bz=\sum_{i=1}^{3}w_ix_i+b

Substituting the values:

z=(0.9)(0)+(0.2)(1.0)+(0.3)(0.5)−0.04z=(0.9)(0)+(0.2)(1.0)+(0.3)(0.5)-0.04

Calculate each term:

(0.9)(0)=0(0.9)(0)=0 (0.2)(1.0)=0.2(0.2)(1.0)=0.2 (0.3)(0.5)=0.15(0.3)(0.5)=0.15

Therefore,

z=0+0.2+0.15−0.04z=0+0.2+0.15-0.04 z=0.31\boxed{z=0.31}

Step 2: Apply the sigmoid activation function

The sigmoid function is:

ฯƒ(z)=11+e−z\boxed{\sigma(z)=\frac{1}{1+e^{-z}}}

For z=0.31z=0.31:

ฯƒ(0.31)=11+e−0.31\sigma(0.31)=\frac{1}{1+e^{-0.31}}

We know:

e−0.31≈0.7334e^{-0.31}\approx0.7334

Therefore:

ฯƒ(0.31)=11+0.7334\sigma(0.31)=\frac{1}{1+0.7334} =11.7334=\frac{1}{1.7334} ฯƒ(0.31)≈0.576\boxed{\sigma(0.31)\approx0.576}

✅ Final Answer

z=0.31\boxed{z=0.31}

and the neuron output is:

y≈0.576\boxed{y\approx0.576}

So, the output of the neuron using sigmoid activation is approximately

Use the following Python Code 

import numpy as np


# defining the Sigmoid Function
def sigmoid (x):
    return 1/(1 + np.exp(-x))

# creating the input array
X=np.array([0,1.0,0.5])
W=np.array([0.9,0.2,0.3])
b=-0.04
o=np.dot(X,W)+b
sigmoutput=sigmoid(o)
print ('\n Output:',sigmoutput)


Output:


Output: 0.5768852611320463

Comments

Popular posts from this blog

Machine Learning PCCST503 Semester5 KTU CS 2024 Scheme - Dr Binu V P

Introduction to Machine Learning (ML)

Distinguishing Machine Learning from Traditional Programming