Artificial Neural Network for NOR Logic Gate with 2-bit Binary Input


Introduction

Artificial Neural Networks (ANNs) have picked up significant attention and have ended up a foundation within the field of artificial intelligence. These computational models, motivated by the complicated workings of the human brain, have appeared exceptional capabilities in fathoming complex issues. ANNs comprise of interconnected nodes, called neurons, which prepare and transmit data through weighted associations. By learning from information, ANNs can recognize designs, make expectations, and perform assignments that were once thought to be solely inside the domain of human insights. In this article, we dig into the usage of an Artificial Neural Network particularly outlined to imitate the NOR logic gate, using a 2−bit binary input.

Logic Gates and NOR Gate

Logic gates are essential building pieces of computerized circuits. They perform consistent operations on one or more parallel inputs and create a binary output. One such rationale entryway is the NOR gate, which stands for "NOT OR." The NOR gate produces an output of 1 (true) as it were when all inputs are (false); something else, it produces an output of (false).

The Truth Table for a 2−bit NOR Gate is as follows:

Input A

Input B

Output

0

0

1

0

1

0

1

0

0

1

1

0

Implementation of NOR Gate Code

Algorithm

Step 1:Import the desired libraries:

Step 2:Import the numpy library as modules.

Step 3:Characterize the step function:

Execute the step_function that takes an input x and returns 1 on the off chance that x is more noteworthy than or rises to 0, something else returns 0.

Step 4:Characterize the weights and inclination:

  • Make a numpy array of weights speaking to the weights for the input information.

  • Set the predisposition value.

Step 5:Characterize the input information:

Make a numpy cluster input_data speaking to the input information for the double classification.

Step 6: Apply the step work:

  • Calculate the weighted whole of inputs and weights utilizing np.dot.

  • Include the predisposition to the weighted whole.

  • Apply the step work to the result utilizing step_function.

Step 7:Print the output:

Print the coming about yield, which speaks to the classification result for each input within the input_data array.

Example

import numpy as np 
 
 
def step_function(x): 
    return np.where(x >= 0, 1, 0) 
  
weights = np.array([-1, -1]) bias 
= 0 
input_data = np.array([[0, 0],             
[0, 1], 
                       [1, 0], 
                       [1, 1]]) 
  
output = step_function(np.dot(input_data, weights) + bias) print(output) 

Output

[1 0 0 0] 

Artificial Neural Network Structure

To execute the NOR logic entryway utilizing an Artificial Neural Network, we got to plan a neural network structure that can learn the mapping between the inputs and the comparing outputs. In this case, we require a neural network with two input neurons and one output neuron.

  • Neuron Inputs:The two input neurons speak to the binary inputs A and B of the NOR entryway. They get the values of or 1, corresponding to the binary inputs.

  • Weights:Each input neuron is related to a weight that decides its commitment to the yield. The weights are movable parameters that the neural arrangement learns amid the training process.

  • Bias:A inclination term is included in each neuron to alter the output limit. It makes a difference in moving the enactment function bend and can be thought of as a pattern input to the neuron.

  • Activation Work:The activation work decides the yield of each neuron based on its weighted whole of inputs and predisposition. In this case, we are going utilize the step function, which returns 1 in case the weighted entirety furthermore predisposition is more noteworthy than or rises to 0, and something else.

Implementation and Results

Employing a programming language such as Python and a machine learning library like TensorFlow or PyTorch, ready to implement the neural organize for the NOR gate with 2bit binary input. By feeding the prepared information through the network and altering the weights and predispositions, the neural network can learn to imitate the behavior of the NOR gate.

After preparing the network, we can assess its execution by testing it on unused input combinations that were not a portion of the prepared information. By comparing the predicted outputs with the anticipated yields, able to assess the exactness of the neural network.

Conclusion

Artificial Neural Networks give an effective device for actualizing complex rationale capacities,such as the NOR gate, employing a combination of interconnected neurons. By preparing the network on fitting input−output sets, the neural network can learn to imitate the behavior of the NOR gate and deliver exact yields for unused input combinations.

Updated on: 26-Jul-2023

240 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements