@Test public void testWeightAccess() { BasicNetwork network = TestBasicNetwork.buildSimpleXOR(); Assert.assertEquals(-0.48463710059519793,network.getWeight(0,0,0), AIFH.DEFAULT_PRECISION); Assert.assertEquals(0.8420570357334933,network.getWeight(0,0,1), AIFH.DEFAULT_PRECISION); Assert.assertEquals(-0.5286518143323836,network.getWeight(0,0,2), AIFH.DEFAULT_PRECISION); Assert.assertEquals(-0.9318070094873679,network.getWeight(0,1,0), AIFH.DEFAULT_PRECISION); Assert.assertEquals(-0.38185835475610996,network.getWeight(0,1,1), AIFH.DEFAULT_PRECISION); Assert.assertEquals(-0.5337936066868234,network.getWeight(0,1,2), AIFH.DEFAULT_PRECISION); Assert.assertEquals(-0.38468537605011033,network.getWeight(0,2,0), AIFH.DEFAULT_PRECISION); Assert.assertEquals(-0.06280032523507262,network.getWeight(0,2,1), AIFH.DEFAULT_PRECISION); Assert.assertEquals(-0.7822212804533125,network.getWeight(0,2,2), AIFH.DEFAULT_PRECISION); Assert.assertEquals(0.13864904435785697,network.getWeight(1,0,0), AIFH.DEFAULT_PRECISION); Assert.assertEquals(-0.1389734035215744,network.getWeight(1,1,0), AIFH.DEFAULT_PRECISION); Assert.assertEquals(0.34318625259753,network.getWeight(1,2,0), AIFH.DEFAULT_PRECISION); }
public double getWeight(final int fromLayer, final int fromNeuron, final int toNeuron) { validateNeuron(fromLayer, fromNeuron); validateNeuron(fromLayer + 1, toNeuron); final int fromLayerNumber = this.layers.size() - fromLayer - 1; final int toLayerNumber = fromLayerNumber - 1; if (toLayerNumber < 0) { throw new AIFHError( "The specified layer is not connected to another layer: " + fromLayer); } final int weightBaseIndex = this.layers.get(fromLayer+1).getWeightIndex(); final int count = this.layers.get(fromLayer).getTotalCount(); final int weightIndex = weightBaseIndex + fromNeuron + (toNeuron * count); return this.weights[weightIndex]; }
BasicNetwork implements RegressionAlgorithm, ClassificationAlgorithm { public double getWeight(final int fromLayer, final int fromNeuron, final int toNeuron) { validateNeuron(fromLayer, fromNeuron); validateNeuron(fromLayer + 1, toNeuron); final int fromLayerNumber = this.layers.size() - fromLayer - 1; final int toLayerNumber = fromLayerNumber - 1; if (toLayerNumber < 0) { throw new AIFHError( "The specified layer is not connected to another layer: " + fromLayer); } final int weightBaseIndex = this.layers.get(fromLayer+1).getWeightIndex(); final int count = this.layers.get(fromLayer).getTotalCount(); final int weightIndex = weightBaseIndex + fromNeuron + (toNeuron * count); return this.weights[weightIndex]; } }
BasicNetwork implements RegressionAlgorithm, ClassificationAlgorithm { public double getWeight(final int fromLayer, final int fromNeuron, final int toNeuron) { validateNeuron(fromLayer, fromNeuron); validateNeuron(fromLayer + 1, toNeuron); final int fromLayerNumber = this.layers.size() - fromLayer - 1; final int toLayerNumber = fromLayerNumber - 1; if (toLayerNumber < 0) { throw new AIFHError( "The specified layer is not connected to another layer: " + fromLayer); } final int weightBaseIndex = this.layers.get(fromLayer+1).getWeightIndex(); final int count = this.layers.get(fromLayer).getTotalCount(); final int weightIndex = weightBaseIndex + fromNeuron + (toNeuron * count); return this.weights[weightIndex]; } BasicNetwork(); }
BasicNetwork implements RegressionAlgorithm, ClassificationAlgorithm { public double getWeight(final int fromLayer, final int fromNeuron, final int toNeuron) { validateNeuron(fromLayer, fromNeuron); validateNeuron(fromLayer + 1, toNeuron); final int fromLayerNumber = this.layers.size() - fromLayer - 1; final int toLayerNumber = fromLayerNumber - 1; if (toLayerNumber < 0) { throw new AIFHError( "The specified layer is not connected to another layer: " + fromLayer); } final int weightBaseIndex = this.layers.get(fromLayer+1).getWeightIndex(); final int count = this.layers.get(fromLayer).getTotalCount(); final int weightIndex = weightBaseIndex + fromNeuron + (toNeuron * count); return this.weights[weightIndex]; } BasicNetwork(); void compute(final double[] input, final double[] output); int getNeuronCount(); int getEncodeLength(); int getInputCount(); double[] getLayerOutput(); int getOutputCount(); double[] getWeights(); void setInputCount(final int inputCount); void setOutputCount(final int outputCount); double[] getLayerSums(); double getWeight(final int fromLayer,
                            final int fromNeuron,
                            final int toNeuron); void validateNeuron(final int targetLayer, final int neuron); int getLayerTotalNeuronCount(final int l); void addLayer(Layer layer); void finalizeStructure(); void clearOutput(); void setWeight(final int fromLayer, final int fromNeuron,
                          final int toNeuron, final double value); void reset(); List<Layer> getLayers(); @Override double[] computeRegression(double[] input); @Override double[] getLongTermMemory(); Layer getNextLayer(Layer layer); Layer getPreviousLayer(Layer layer); @Override int computeClassification(double[] input); boolean isNetworkTraining(); void setNetworkTraining(boolean networkTraining); }
BasicNetwork implements RegressionAlgorithm, ClassificationAlgorithm { public double getWeight(final int fromLayer, final int fromNeuron, final int toNeuron) { validateNeuron(fromLayer, fromNeuron); validateNeuron(fromLayer + 1, toNeuron); final int fromLayerNumber = this.layers.size() - fromLayer - 1; final int toLayerNumber = fromLayerNumber - 1; if (toLayerNumber < 0) { throw new AIFHError( "The specified layer is not connected to another layer: " + fromLayer); } final int weightBaseIndex = this.layers.get(fromLayer+1).getWeightIndex(); final int count = this.layers.get(fromLayer).getTotalCount(); final int weightIndex = weightBaseIndex + fromNeuron + (toNeuron * count); return this.weights[weightIndex]; } BasicNetwork(); void compute(final double[] input, final double[] output); int getNeuronCount(); int getEncodeLength(); int getInputCount(); double[] getLayerOutput(); int getOutputCount(); double[] getWeights(); void setInputCount(final int inputCount); void setOutputCount(final int outputCount); double[] getLayerSums(); double getWeight(final int fromLayer,
                            final int fromNeuron,
                            final int toNeuron); void validateNeuron(final int targetLayer, final int neuron); int getLayerTotalNeuronCount(final int l); void addLayer(Layer layer); void finalizeStructure(); void clearOutput(); void setWeight(final int fromLayer, final int fromNeuron,
                          final int toNeuron, final double value); void reset(); List<Layer> getLayers(); @Override double[] computeRegression(double[] input); @Override double[] getLongTermMemory(); Layer getNextLayer(Layer layer); Layer getPreviousLayer(Layer layer); @Override int computeClassification(double[] input); boolean isNetworkTraining(); void setNetworkTraining(boolean networkTraining);  }