Implementing ANDNOT Gate using Adaline Network
ADALINE (Adaptive Linear Neuron or later Adaptive Linear Element) is an early single-layer artificial neural network and the name of the physical device that implemented this network. The problem here is to implement AND-NOT using Adaline network. Here we perform 5 epochs of training and calculate total mean error in each case, the total mean error decreases after each epochs and later becomes nearly constant.
The Truth Table for AND-NOT Gate is as follows: x1 x2 t 1 1 -1 1 -1 1 -1 1 -1 -1 -1 -1
#include <iostream> using namespace std; int main() { // input array int arr[4][2] = { { 1, 1 }, { 1, -1 }, { -1, 1 }, { -1, -1 } }; // target array int t[4] = { -1, 1, -1, -1 }, i, j; float yi, dif, dw1, dw2, db, w1 = 0.2, w2 = 0.2, b = 0.2, err[4]; // taking bias in each case as 1 // Calculation upto 5 epochs // consider learning rate = 0.2 for (i = 0; i < 5; i++) { float avg = 0; cout << "EPOCH " << i + 1 << " Errors" << endl << endl; for (j = 0; j < 4; j++) { // calculating net input yi = arr[j][0] * w1 + arr[j][1] * w2 + 1 * b; dif = t[j] - yi; // updated weights w1 += 0.2 * dif * arr[j][0]; w2 += 0.2 * dif * arr[j][1]; b += 0.2 * dif * 1; err[j] = dif * dif; cout << err[j] << " "; avg += err[j]; } cout << endl << "Total Mean Error :" << avg << endl << endl << endl; } return 0; } |
EPOCH 1 Errors 2.56 1.2544 0.430336 1.47088 Total Mean Error :5.71562 EPOCH 2 Errors 0.951327 0.569168 0.106353 0.803357 Total Mean Error :2.43021 EPOCH 3 Errors 0.617033 0.494715 0.369035 0.604961 Total Mean Error :2.08574 EPOCH 4 Errors 0.535726 0.496723 0.470452 0.541166 Total Mean Error :2.04407 EPOCH 5 Errors 0.515577 0.503857 0.499932 0.520188 Total Mean Error :2.03955
Recommended Posts:
- Implementing Artificial Neural Network training process in Python
- OR Gate using Perceptron Network
- Implementing Multidimensional Map in C++
- ML | Implementing L1 and L2 regularization using Sklearn
- ML | OPTICS Clustering Implementing using Sklearn
- Implementing Agglomerative Clustering using Sklearn
- Implementing DBSCAN algorithm using Sklearn
- Implementing Apriori algorithm in Python
- Implementing Deep Q-Learning using Tensorflow
- Generative Adversarial Network (GAN)
- Introduction to ANN | Set 4 (Network Architectures)
- Introduction to Artificial Neural Network | Set 2
- Introduction to Recurrent Neural Network
- Introduction to Convolution Neural Network
- Importance of Convolutional Neural Network | ML
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

