Hello, I've decided to look into the subject of AI programming, and am having trouble with changing my weights with the delta rule. I'm trying to make a simple Boolean AND logic perceptron, which will learn to recognize whether both the inputs are the same.
Here's my code that I have so far:
There is no problem, except once I "train" the perceptron, and the feed it 2 inputs like 1 and 0, it would evaluate to true, but seeing both the inputs aren't true, it shouldn't.Code:// Include header files #include <iostream> using namespace std; int main() { // Delcare vars double threshold = 1.0; double weight = -0.2; double activation; int input1, input2; bool output; // Keep looping while (1) { // Get the input vars cout << "Please enter the first boolean input: "; cin >> input1; cout << "Please enter the second boolean input: "; cin >> input2; // Get the activation activation = (input1 * weight) + (input2 * weight); // If the activation is greater than the threshold, fire the perceptron if (activation >= threshold) { cout << "Perceptron is firing" << endl; output = true; } // If the activation is less than the threshold, don't fire else if (activation < threshold) { output = false; cout << "Perceptron isn't firing" << endl; cout << "Changing Weights..." << endl; cout << "Old Weight: " << weight << endl; // Change the weights weight += (input1 + input2) * (1 - output); cout << "New Weight: " << weight << endl; } system("pause"); system("cls"); } return 0; }
I don't know, but it may be the way I'm adjusting the weights, I'm using the delta rule off the cprogramming tutorials, and I may have interpreted it wrong.
I will admit right now that I'm just starting in this subject, so it's probably some simple mistake, or something that I've overlooked. If anyone has any suggestions, or a solution, it would be appreciated.



LinkBack URL
About LinkBacks


