Package zdenekdrahos.AI.NeuralNetwork.Layers

Examples of zdenekdrahos.AI.NeuralNetwork.Layers.ILayer


            }
        }
    }

    public static void assertNetworkWeights(INeuralNetwork network, double[][][] expectedWeights) {
        ILayer layer;
        List<IWeight> currentWeights;
        int previousNeuronIndex;
        for (int layerIndex = 1; layerIndex < network.getLayersCount(); layerIndex++) {
            layer = network.getLayer(layerIndex);
            for (int neuronIndex = 0; neuronIndex < layer.getNeuronsCount(); neuronIndex++) {
                currentWeights = network.getWeights().getNeuronWeights(layerIndex, neuronIndex);
                previousNeuronIndex = 0;
                for (IWeight weight : currentWeights) {
                    assertEquals(weight.getWeight(), expectedWeights[layerIndex - 1][neuronIndex][previousNeuronIndex++], 0.1);
                }
View Full Code Here


    private INeuralNetwork network = new NeuralNetwork();
    private IActivationFactory factory = new ActivationFactory();

    @Test
    public void testAddLayer() {
        ILayer layer = new Layer(1, factory.getLinearFunction());
        assertEquals(0, network.getLayersCount());
        network.addLayer(layer);       
        assertEquals(1, network.getLayersCount());
        network.addLayer(layer);
        assertEquals(2, network.getLayersCount());
View Full Code Here

        //input = new double[]{0, 0};
        //output = new double[]{1, 1};

        IActivationFactory factory = new ActivationFactory();
        ILayer inputLayer = new Layer(1, factory.getLinearFunction());
        ILayer hiddenLayer1 = new Layer(4, factory.getHyperbolicTangent());
        ILayer hiddenLayer2 = new Layer(4, factory.getHyperbolicTangent());
        ILayer outputLayer = new Layer(1, factory.getLinearFunction());

        // check
        if (input.length != output.length || input.length != inputLayer.getNeuronsCount() || output.length != outputLayer.getNeuronsCount()) {
            System.exit(1);
        }

        network = new ILayer[]{inputLayer, hiddenLayer1, outputLayer};
View Full Code Here

            System.out.println();
        }
    }

    public static void printNetworkWeights(INeuralNetwork network) {
        ILayer layer;
        List<IWeight> weights;
        IWeights networkWeights = network.getWeights();

        for (int layerIndex = 1; layerIndex < network.getLayersCount(); layerIndex++) {
            layer = network.getLayer(layerIndex);
            System.out.printf("%d -> %d layer\n", layerIndex - 1, layerIndex);
            for (int neuronIndex = 0; neuronIndex < layer.getNeuronsCount(); neuronIndex++) {
                System.out.printf("%d.neuron = ", neuronIndex);
                weights = networkWeights.getNeuronWeights(layerIndex, neuronIndex);
                for (IWeight weight : weights) {
                    System.out.printf("%f  ", weight.getWeight());
                }
View Full Code Here

    }

    @Override
    public void create(INeuralNetwork network, double[][][] initialWeights) {
        weights = new HashMap<Integer, List<List<IWeight>>>();
        ILayer currentLayer, previousLayer;
        IWeight weight;
        for (int layerIndex = 1; layerIndex < network.getLayersCount(); layerIndex++) {           
            previousLayer = network.getLayer(layerIndex - 1);
            currentLayer = network.getLayer(layerIndex);
            createListsForLayer(layerIndex, currentLayer);
            for (int neuronIndex = 0; neuronIndex < currentLayer.getNeuronsCount(); neuronIndex++) {
                createListForNeuron(layerIndex, previousLayer);
                for (int previousNeuronIndex = 0; previousNeuronIndex <= previousLayer.getNeuronsCount(); previousNeuronIndex++) {                   
                    weight = new Weight();
                    try {
                        weight.setWeight(initialWeights[layerIndex - 1][neuronIndex][previousNeuronIndex]);
View Full Code Here

    public INeuralNetwork build(int[] topology, Activations[] functions) {
        if (topology.length != functions.length) {
            throw new IllegalArgumentException("Layers & functions - different length");
        }
        INeuralNetwork network = new NeuralNetwork();
        ILayer layer;
        for (int i = 0; i < topology.length; i++) {
            layer = new Layer(topology[i], getActivation(functions[i]));
            network.addLayer(layer);
        }
        network.generateWeights();
View Full Code Here

TOP

Related Classes of zdenekdrahos.AI.NeuralNetwork.Layers.ILayer

Copyright © 2018 www.massapicom. 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.