Artificial IntelligencePython

A single neuron in a neural network.


Artificial Intelligence is a simulation where machines mimics the capabilities of human and may surpass the human intelligence to perform some tasks.

The power house of human intelligence is the brain. So the basic instinct we get is why not create an artificial brain which can become the power house of machine with artificial intelligence.

The anatomy of a brain?

Brain On a macro level

This is what a human rain looks like on a macro level.

But we are not interested in what it looks like we are interested in how the brain works, what is the smallet building block of human intelligence which can be simulated on a machine.


The human nervous system is made up of a a unique type of cell called the neurons which are responsible to transmit signals from one cell to other.

And it turns out that the Human brain consists an average of 86 billion neurons.

Neuron structure

Structure of a Biological neuron?

Dendrite: A treelike extension of the neuron cell body. The dendrite is the primary site for receiving and integrating information from other neurons.

Axon: The fiber-like extension of a neuron by which it sends information to target cells.

Cell Body: Also called the soma, the part of a neuron that contains the nucleus (with DNA) and the organelles, but not the projections such as the axon or dendrites.

Making an Artificial Neuron.

Now that we know what neurons are made up of we can design an artificial neuron.

The anatomy of an artificial will have three major parts namely:

  1. The Input / Dendrite
  2. The processing unit / cell body
  3. The output / Axons
Artificial neuron inspired by biological neuron

Simplified Block Representation of a Neuron.

Artificial Neuron Block Diagram

Mathematical Recipie

Before we jump to make a python programs lets first understand what is the mathematical recipe to make a neuron.

So to make a neuron you will need .

  1. x inputs (collecting the ingredients)
  2. w weights associated with the input, weights the quantity of the input which goes in the summation function,hence deciding which input will effect the least and most, input weights changes as the model trains. Better the weights better the results. (generally weights ranges from 0 to 1)
  3. a summation function ( mixing all the input ingredients)
  4. a activation function (processing the mixture)
  5. and finally you will get a y output ( result)

So Finally we get a formula of a neuron:

Neuron Formula

Python Program of a simple Neuron.

Now that we have all the specification of a neuron we can create one in any programming language we want.

I will be using python and would appreciate if you translate and the same code in any other programming language you like.

Check how to install Anaconda (Python) on Linux.

Will be using numpy library which the most common and robust library for mathematical computation.

Summation Function: It is just the sum all the weighted inputs.

For simplicity we will be using a step activation function and hence creating a perceptron neuron.

Step Activation Function: If the input (from summation block) is <= 0 the output is 0 else the output is 1.

Step Function

The Neuron Code :

Final Code

Download the code and your push changes on github: Give me the Code

Feel free to comment and subscribe to our blog its free forever.

Follow on :

Write a great article and get featured on our blog. Intrested? drop a message on FB, instagram, linkedin or you can mail us too. Looking forward to what you have got to share .

Email us : [email protected]

0 0 vote
Article Rating
Notify of
Inline Feedbacks
View all comments

Comment here