in

is Odd With Neural Networks

is Odd With Neural Networks

public static void main(String[l args) {l

int TRAINING_SIZE = 300;

int TESTING_SIZE = 100;

Perceptron p = new Perceptron(;

25262728

34353637383948

4142

// Generate random numbers between 0 and 255 (8 bits)

Random r = new Random ;

for (int i = 0; i ‹ TRAINING_SIZE; i++) {

Digit d = new Digit( r.nextInt(0, 255) );

p. train( d.getBinary(), d.getLabel() );

}

// Testing Phase

// Generate more random numbers and evaluate the Perceptron’s trained model.

int correct = 0;

for (int i = 0; i ‹ TESTING_SIZE; i++) {

Digit d = new Digit( r.nextInt(0, 255) );

if ( d. getLabel () == p. guess ( d. getBinary () ))

correct++;

}

// Output the percent of times the Perceptron correctly identified whether

// a number was odd or even.

System.out.printf(“Percent Correct: %.2f%%\n”, (correct/(TESTING_SIZE*1.0))*100);

System.out.print(“Final Perceptron Weights: “);

printArray ( p. getWeights () );

Percent Correct: 96.00%

Final Perceptron Weights: [-0.0030, 0.0250, 0.0150, 0.0250, 0.0250, 0.0130, 0.0070, -0.09101]

What do you think?

Written by codeitbro

Codeitbro.in is a hub of funny coding and programming memes. Explore memes on various topics such as cybersecurity, Linux, Software Testing, and many others.

Leave a Reply

Your email address will not be published. Required fields are marked *

GIPHY App Key not set. Please check settings