@Test public void testComputeRegression() { final RBFNetwork network = new RBFNetwork(2, 1, 1); final double[] ltm = { 2.0, 2.0, 5.0, 2.0, 4.0, 3.0, 4.0}; System.arraycopy(ltm, 0, network.getLongTermMemory(), 0, ltm.length); final double[] x = {1, 2}; final double y = network.computeRegression(x)[0]; assertEquals(7, y, AIFH.DEFAULT_PRECISION); }
@Override public double[] computeRegression(final double[] input) { final double[] rbfOutput = new double[rbf.length + 1]; rbfOutput[rbfOutput.length - 1] = 1; for (int rbfIndex = 0; rbfIndex < rbf.length; rbfIndex++) { final double[] weightedInput = new double[input.length]; for (int inputIndex = 0; inputIndex < input.length; inputIndex++) { final int memoryIndex = this.indexInputWeights + (rbfIndex * this.inputCount) + inputIndex; weightedInput[inputIndex] = input[inputIndex] * this.longTermMemory[memoryIndex]; } rbfOutput[rbfIndex] = this.rbf[rbfIndex].evaluate(weightedInput); } final double[] result = new double[this.outputCount]; for (int outputIndex = 0; outputIndex < result.length; outputIndex++) { double sum = 0; for (int rbfIndex = 0; rbfIndex < rbfOutput.length; rbfIndex++) { final int memoryIndex = this.indexOutputWeights + (outputIndex * (rbf.length + 1)) + rbfIndex; sum += rbfOutput[rbfIndex] * this.longTermMemory[memoryIndex]; } result[outputIndex] = sum; } return result; }
RBFNetwork implements RegressionAlgorithm, ClassificationAlgorithm { @Override public double[] computeRegression(final double[] input) { final double[] rbfOutput = new double[rbf.length + 1]; rbfOutput[rbfOutput.length - 1] = 1; for (int rbfIndex = 0; rbfIndex < rbf.length; rbfIndex++) { final double[] weightedInput = new double[input.length]; for (int inputIndex = 0; inputIndex < input.length; inputIndex++) { final int memoryIndex = this.indexInputWeights + (rbfIndex * this.inputCount) + inputIndex; weightedInput[inputIndex] = input[inputIndex] * this.longTermMemory[memoryIndex]; } rbfOutput[rbfIndex] = this.rbf[rbfIndex].evaluate(weightedInput); } final double[] result = new double[this.outputCount]; for (int outputIndex = 0; outputIndex < result.length; outputIndex++) { double sum = 0; for (int rbfIndex = 0; rbfIndex < rbfOutput.length; rbfIndex++) { final int memoryIndex = this.indexOutputWeights + (outputIndex * (rbf.length + 1)) + rbfIndex; sum += rbfOutput[rbfIndex] * this.longTermMemory[memoryIndex]; } result[outputIndex] = sum; } return result; } }
RBFNetwork implements RegressionAlgorithm, ClassificationAlgorithm { @Override public double[] computeRegression(final double[] input) { final double[] rbfOutput = new double[rbf.length + 1]; rbfOutput[rbfOutput.length - 1] = 1; for (int rbfIndex = 0; rbfIndex < rbf.length; rbfIndex++) { final double[] weightedInput = new double[input.length]; for (int inputIndex = 0; inputIndex < input.length; inputIndex++) { final int memoryIndex = this.indexInputWeights + (rbfIndex * this.inputCount) + inputIndex; weightedInput[inputIndex] = input[inputIndex] * this.longTermMemory[memoryIndex]; } rbfOutput[rbfIndex] = this.rbf[rbfIndex].evaluate(weightedInput); } final double[] result = new double[this.outputCount]; for (int outputIndex = 0; outputIndex < result.length; outputIndex++) { double sum = 0; for (int rbfIndex = 0; rbfIndex < rbfOutput.length; rbfIndex++) { final int memoryIndex = this.indexOutputWeights + (outputIndex * (rbf.length + 1)) + rbfIndex; sum += rbfOutput[rbfIndex] * this.longTermMemory[memoryIndex]; } result[outputIndex] = sum; } return result; } RBFNetwork(final int theInputCount, final int rbfCount, final int theOutputCount); }
RBFNetwork implements RegressionAlgorithm, ClassificationAlgorithm { @Override public double[] computeRegression(final double[] input) { final double[] rbfOutput = new double[rbf.length + 1]; rbfOutput[rbfOutput.length - 1] = 1; for (int rbfIndex = 0; rbfIndex < rbf.length; rbfIndex++) { final double[] weightedInput = new double[input.length]; for (int inputIndex = 0; inputIndex < input.length; inputIndex++) { final int memoryIndex = this.indexInputWeights + (rbfIndex * this.inputCount) + inputIndex; weightedInput[inputIndex] = input[inputIndex] * this.longTermMemory[memoryIndex]; } rbfOutput[rbfIndex] = this.rbf[rbfIndex].evaluate(weightedInput); } final double[] result = new double[this.outputCount]; for (int outputIndex = 0; outputIndex < result.length; outputIndex++) { double sum = 0; for (int rbfIndex = 0; rbfIndex < rbfOutput.length; rbfIndex++) { final int memoryIndex = this.indexOutputWeights + (outputIndex * (rbf.length + 1)) + rbfIndex; sum += rbfOutput[rbfIndex] * this.longTermMemory[memoryIndex]; } result[outputIndex] = sum; } return result; } RBFNetwork(final int theInputCount, final int rbfCount, final int theOutputCount); @Override double[] computeRegression(final double[] input); @Override double[] getLongTermMemory(); void reset(final GenerateRandom rnd); @Override int computeClassification(final double[] input); @Override String toString(); }
RBFNetwork implements RegressionAlgorithm, ClassificationAlgorithm { @Override public double[] computeRegression(final double[] input) { final double[] rbfOutput = new double[rbf.length + 1]; rbfOutput[rbfOutput.length - 1] = 1; for (int rbfIndex = 0; rbfIndex < rbf.length; rbfIndex++) { final double[] weightedInput = new double[input.length]; for (int inputIndex = 0; inputIndex < input.length; inputIndex++) { final int memoryIndex = this.indexInputWeights + (rbfIndex * this.inputCount) + inputIndex; weightedInput[inputIndex] = input[inputIndex] * this.longTermMemory[memoryIndex]; } rbfOutput[rbfIndex] = this.rbf[rbfIndex].evaluate(weightedInput); } final double[] result = new double[this.outputCount]; for (int outputIndex = 0; outputIndex < result.length; outputIndex++) { double sum = 0; for (int rbfIndex = 0; rbfIndex < rbfOutput.length; rbfIndex++) { final int memoryIndex = this.indexOutputWeights + (outputIndex * (rbf.length + 1)) + rbfIndex; sum += rbfOutput[rbfIndex] * this.longTermMemory[memoryIndex]; } result[outputIndex] = sum; } return result; } RBFNetwork(final int theInputCount, final int rbfCount, final int theOutputCount); @Override double[] computeRegression(final double[] input); @Override double[] getLongTermMemory(); void reset(final GenerateRandom rnd); @Override int computeClassification(final double[] input); @Override String toString();  }