Showing posts with label Artificial Neural Network. Show all posts
Showing posts with label Artificial Neural Network. Show all posts

Logic Gates In Artificial Neural Network and mesh Ploting using Matlab

In this part, you are required to demonstrate the capability of a single-layer perceptron to model the following logic gates:
AND , OR , NOT , XOR
Generate the output curves/surfaces for these perceptron-models as the input/s vary continuously from 0.0 to 1.0 (hint: mesh function can come in handy)

And Gate

%input perseptrons
p=[0 0 1 1;0 1 0 1];
%Output Perseptrons
t=[0 0 0 1];
%creation of new pereceptron
net=newp([0 1;0 1],1)
%plot input/outpur
plotpv(p,t);
grid on;
%train the perceptron at 100 iterations
net.trainParam.passes=100;
%assign perceptron to net value
[net,a,e]=train(net,p,t);
%Border Line of the Active function
plotpc(net.iw{1,1},net.b{1})
%To plot the mesh Surface
y = ones(11,11);
input = 0:0.1:1;
for i = 0:10
for j = 0:10
y(i + 1,j + 1) = sim(net,[i/10;j/10]);
end
end
mesh(input,input,y)
colormap([1 0 0; 0 1 1])







Or Gate

%input perseptrons
p=[0 0 1 1;0 1 0 1];
%Output Perseptrons
t=[0 1 1 1];
%creation of new pereceptron
net=newp([0 1;0 1],1)
%plot input/outpur
plotpv(p,t);
grid on;
%train the perceptron at 100 iterations
net.trainParam.passes=100;
%assign perceptron to net value
[net,a,e]=train(net,p,t);
%Border Line of the Active function
plotpc(net.iw{1,1},net.b{1})
a=sim(net,[1;1])
%To plot the mesh Surface
y = ones(11,11);
input = 0:0.1:1;
for i = 0:10
for j = 0:10
y(i + 1,j + 1) = sim(net,[i/10;j/10]);
end
end
mesh(input,input,y)
colormap([1 0 0; 0 1 1])



Not Gate

%input perseptrons
p=[0 1];
%Output Perseptrons
t=[1 0];
%creation of new pereceptron
net=newp([0 1],1)
%plot input/outpur
plotpv(p,t);
grid on;
%train the perceptron at 100 iterations
net.trainParam.passes=100;
%assign perceptron to net value
[net,a,e]=train(net,p,t);
%Border Line of the Active function
plotpc(net.iw{1,1},net.b{1})
a=sim(net,1)




Neural Model for Random Data

%in/Out values
%------------------
%| In1  | In2  |Out|
%|------|------|---|
%| 100  | 200  | 0 |
%| 0.15 | 0.23 | 0 |
%| 0.33 | 0.46 | 0 |
%| 0.42 | 0.57 | 1 |
%------------------

input=[ 100 0.15 0.33 0.42;150 0.23 0.46 0.57];

%here we can use the output value as 0 and 1.
%Because we are using hardlimit threshold function.
%The values are 0 or 1
target=[0 0 0 1];
%creation of new pereceptron
net=newp([0 1;0 1],1);
%plot input/outpur
plotpv(input,target);
grid on;
%train the perceptron at 100 iterations
net.trainParam.passes=100;
%assign perceptron to net value
[net,a,e]=train(net,input,target);
%Active border line
plotpc(net.iw{1,1},net.b{1})
hold on
%second Inputs
p2=[0.20 0.6 0.1;0.20 0.9 0.4];
t2=sim(net,p2)
plotpv(p2,t2);
[net, a, e]= train(net,p2,t2);
plotpc(net.iw{1,1},net.b{1});
hold off




Difference Between Human Brain And Artificial Neural Network

On the matter of memory, there is no comparision. Neural networks are potentially faster and more accurate than humans.


Human Behavior
When a child is born, what does the child know? To our knowledge, the child knows only how to cry. The child probably does not know its parents. When the child grows, the step by step learning process begins. First, the child learns to drink milk. Then the child learns to identify its parents. Every time a child learns something, it is encoded into some portion of the brain.
Yet there is a difference in the way the information is stored in brain. Some information or instances are "hard-coded" within the brain. As a result, we never forget certain things. For example, once we learn to swim, we never forget swimming. Though it appears normal to say that we know swimming, there is a mystery behind this. Why are we unable to forget the swimming? The reason might be that when we are fully trained to swim, it is hard-coded into our brain. There are many examples of unforgettable information. Another example is once we learn that 1 + 1 equals 2, we never forget that fact. Why? The reason is that it is completely learned.
These examples demonstrate that we can learn, understand and remember certain things completely, partially and sometimes not at all. Depending on our capacity for learning, the information is stored in our brain. Whatever is incompletely learned will lose its strength and not be retained in our brain. So, if we do not practice what we learned, we start to forget. Consequently, by practice or training, we can hard-code some selected things into our brains. Naturally, we cannot become expert in all areas. For example, it is difficult for one person to learn all of civil, computer, mechanical and electrical engineering along with medicine. We choose our subject areas based on our subjective interests. Even if you learn computer engineering, there are several areas within computer science. We cannot learn all areas and become an expert on everything in computer science. We choose one area and become inquisitive in that area searching for extreme interest. Finally, when we prove that we know much of that area, we are regarded as an expert in that area.
Many neuroscientists believe that learning stimulates new dendrite connections between neurons. Greater usage of the brain through learning and stimulation creates greater dendrite connectivity. Thus, as we learn more and more, we become more intelligent. Wisdom is not created through genetics. Wisdom and knowledge are based on how we learn and how we practice what we learned.

Neural Network Behavior
Now let us compare this human activity with neural networks. Whenever we create a new neural network, it is like giving birth to a child. After giving birth, we start to train the network. Not surprisingly, we may have created the neural network for certain applications or purposes. Here, the difference between childbirth and neural networks is obvious; first, we decide why we need a neural net and create it. Childbirth results are random in nature. When a child is born we do not know where the child will concentrate its studies through life. We leave it in the hands of the child and its parents. Naturally, parents play an extremely important role in child development and this is similar to the person creating a neural network. In the same way that a child becomes an expert in an area, we train the neural networks to become expert in an area. Once we establish an automatic learning mechanism in neural networks, it practices and starts to learn on its own and does its work as expected. Once it is proven that the neural network is doing its intended job correctly, we call it an "expert" and it operates according to its own decisions and judgment.
In our daily life, in many instances we have already transferred decision-making processes to computers. For example, say you attempt to purchase a product using a credit card over the Internet. For some reason, the billing address does not match the mailing address; it may be due to missing letters or misspelled words or other reasons. Although you are the correct person using a valid credit card, the purchase does not go through because the seller's computer does not allow transactions with a mismatch in the address. Based on this computer verification, the seller decides not to process your request. Although instances such as this happen daily in our lives, we tend to forget the computer's role in the decision.

Comparison
Now the question remains, what is the difference between human and neural networks? Both can learn and become expert in an area and both are mortal. The main difference is, humans can forget but neural networks cannot. Once fully trained, a neural net will not forget. Whatever a neural network learns is hard-coded and becomes permanent. A human's knowledge is volatile and may not become permanent. There are several factors that cause our brain cells to die and if they do, the information that is stored in that part is lost and we start to forget.
The other difference is accuracy. Once a particular application or process is automated through a neural network, the results are repeatable and accurate. Whether the process is replicated one thousand times or one million times, the results will be the same and will be as accurate as calculated the first time. Human beings are not like that. The first 10 processes may be accurate, but later we may start to make mistakes in the process. Another key difference is speed. Neural networks can be hardware or software. It is obvious that neural networks are much faster than humans in processing data and information.



Introduction To Artificial Neural Network

 
Human can identify a  person through  thoughts.which means humans neurons are getting trained itself. Therefore through Artificial Neural Network we can train artificial neurons using computer programming . using neural network we are trying to build a network between neurons to transfer the electrical signals.which are consists of neural commands .

usually Computer response time is  10^6 times  faster than humans response time because of the silicon Integrated chips.
silicon chip  response time :- 1 nanosecond
human response time         :- 1 millisecond

but  human can perform faster than chips because human has massively parallel neural structure. If we consider human neuron structure it has synaptic terminals, cell body(neurons), basal dendrite and axon. Each components has some function to transfer signal to neurons.                                                                                                                                                         

Also we can map Human neurons with Artificial neurons  as bellow... 

Human neurons

Artificial neurons
                Neurons
Neurons
Axon Wkj (weight)
Synaptic terminals
to next neuron
output terminals

Synaptic terminals
taking input
input terminals (Xj)