|
import java.util.Vector;
import org.neuroph.core.learning.SupervisedTrainingElement;
import org.neuroph.core.learning.TrainingSet;
import org.neuroph.nnet.MultiLayerPerceptron;
import org.neuroph.nnet.learning.MomentumBackpropagation;
public class BenchmarkNeuroph implements Benchmarkable {
private MultiLayerPerceptron network;
private TrainingSet trainingSet;
private MomentumBackpropagation train;
@Override
public void prepareBenchmark(double[][] input, double[][] ideal) {
this.network = new MultiLayerPerceptron(
input[0].length,
Benchmark.HIDDEN_COUNT,
ideal[0].length);
this.trainingSet = new TrainingSet();
for(int i=0;i<input.length;i++)
{
SupervisedTrainingElement element = new SupervisedTrainingElement(input[i],ideal[i]);
trainingSet.addElement(element);
}
this.train = new MomentumBackpropagation(network);
train.setTrainingSet(trainingSet);
train.setMaxIterations(Benchmark.ITERATIONS);
train.setLearningRate(Benchmark.LEARNING_RATE);
train.setMomentum(Benchmark.MOMENTUM);
train.setMaxError(Double.MIN_VALUE);
train.setMinErrorChange(Double.MIN_VALUE);
}
@Override
public double benchmark(int iterations) {
train.setMaxIterations(iterations);
train.run();
return train.getTotalNetworkError().doubleValue();
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Hello, I am a student at Rutgers University. I am in computer science and am learning about machine learning and AI.