|
import org.encog.neural.activation.ActivationSigmoid;
import org.encog.neural.data.NeuralDataSet;
import org.encog.neural.data.basic.BasicNeuralDataSet;
import org.encog.neural.networks.BasicNetwork;
import org.encog.neural.networks.layers.BasicLayer;
import org.encog.neural.networks.logic.FeedforwardLogic;
import org.encog.neural.networks.training.Train;
import org.encog.neural.networks.training.propagation.back.Backpropagation;
import org.encog.util.logging.Logging;
public class BenchmarkEncog implements Benchmarkable {
private BasicNetwork network;
private NeuralDataSet trainingSet;
private Backpropagation train;
private int threadCount;
public BenchmarkEncog(int threadCount)
{
this.threadCount = threadCount;
}
@Override
public double benchmark(int iterations) {
// train the neural network
int epoch = 1;
do {
train.iteration();
epoch++;
} while (epoch <= Benchmark.ITERATIONS );
return 0;
}
@Override
public void prepareBenchmark(double[][] input, double[][] ideal) {
// construct a network
this.network = new BasicNetwork();
network.addLayer(new BasicLayer(new ActivationSigmoid(),true,Benchmark.INPUT_COUNT));
network.addLayer(new BasicLayer(new ActivationSigmoid(),true,Benchmark.HIDDEN_COUNT));
network.addLayer(new BasicLayer(new ActivationSigmoid(),true,Benchmark.OUTPUT_COUNT));
network.setLogic(new FeedforwardLogic());
network.getStructure().finalizeStructure();
network.reset();
// construct training data
this.trainingSet = new BasicNeuralDataSet(input, ideal);
this.train = new Backpropagation(this.network, this.trainingSet,
Benchmark.LEARNING_RATE, Benchmark.MOMENTUM);
this.train.setNumThreads(this.threadCount);
}
}
|
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.