Package zdenekdrahos.AI.Training.Simulation

Source Code of zdenekdrahos.AI.Training.Simulation.Simulation

/*
* JAVA Neural Networks (https://bitbucket.org/zdenekdrahos/java-neural-networks)
* @license New BSD License
* @author Zdenek Drahos
*/

package zdenekdrahos.AI.Training.Simulation;

import java.util.List;
import zdenekdrahos.AI.FeedForward.FeedForward;
import zdenekdrahos.AI.FeedForward.IFeedForward;
import zdenekdrahos.AI.FeedForward.INetworkValues;
import zdenekdrahos.AI.NeuralNetwork.INeuralNetwork;

public class Simulation implements ISimulation {

    private IFeedForward feedForward = new FeedForward();
    private INeuralNetwork network;
    private int indexOfOutputLayer;
    private List<Double> lastSimulation;

    @Override
    public void setNetwork(INeuralNetwork network) {
        this.network = network;
        indexOfOutputLayer = network.getOutputLayerIndex();
    }

    @Override
    public void simulate(double[] inputPattern) {
        if (network == null) {
            throw new NullPointerException("Network");
        }
        INetworkValues values = feedForward.buildNetwork(network, inputPattern);
        lastSimulation = values.getLayerValues(indexOfOutputLayer);
    }

    @Override
    public Double get(int neuronIndex) {
        if (network == null) {
            throw new NullPointerException("Network");
        }
        return lastSimulation.get(neuronIndex);
    }
}
TOP

Related Classes of zdenekdrahos.AI.Training.Simulation.Simulation

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.