📄 neuralnetwork.java
字号:
j++) { double input = 0; // Input for each neuron: for (int k = 0; k < staticLayers[i - 1].getLayerSize(); k++) { input = input + staticLayers[i - 1] .getNeuron(k) .getOutputValue() * staticLayers[i] .getWeight( k, j); } input = input + staticLayers[i].getBias(j); staticLayers[i].getNeuron(j).setInput( input); staticLayers[i] .getNeuron(j) .calculateOutputValue(); } } // Sets the result vector: for (int i = 0; i < staticLayers[networkSize - 1].getLayerSize(); i++) { this.staticResultValues[i] = staticLayers[networkSize - 1].getNeuron(i).getOutputValue(); } } break; case NeuralNetwork.NOT_MULTICONEXED : { // TODO Implement this. } break; } } break; case NeuralNetwork.DYNAMIC : { // TODO Implement this. } break; } } //propagateInput() /* (non-Javadoc) * @see neuralnetworktoolkit.INeuralNetwork#numberOfSynapses() */ public int numberOfSynapses() { int result = 0; switch (isDynamic) { case NeuralNetwork.NOT_DYNAMIC : { switch (isMultiConexed) { case NeuralNetwork.MULTICONEXED : { result = inputSize * staticLayers[0].getLayerSize() + staticLayers[0].getLayerSize(); for (int i = 0; i < networkSize - 1; i++) { result = result + staticLayers[i].getLayerSize() * staticLayers[i + 1].getLayerSize() + staticLayers[i + 1].getLayerSize(); } } break; case NeuralNetwork.NOT_MULTICONEXED : { // TODO Implement this. } break; } } break; case NeuralNetwork.DYNAMIC : { // TODO Implement this. } break; } return result; } //numberOfSynapses() /* (non-Javadoc) * @see neuralnetworktoolkit.INeuralNetwork#getOutputLayer() */ public ILayer getOutputLayer() { ILayer result = null; switch (isDynamic) { case NeuralNetwork.NOT_DYNAMIC : { result = (ILayer) staticLayers[networkSize - 1]; } break; case NeuralNetwork.DYNAMIC : { result = (ILayer) dynamicLayers.elementAt(networkSize - 1); } break; } return result; } //getOutputLayer() /* (non-Javadoc) * @see neuralnetworktoolkit.INeuralNetwork#retrieveFinalResults() */ public double[] retrieveFinalResults() { return (double[])staticResultValues.clone(); } //retrieveFinalResults /** * Sets if the network is dynamic or not. * * @param condition Network condition. */ public void setIsDynamic(int condition) { isDynamic = condition; } //setIsDynamic() /** * Sets if the network is multiconexed or not. * * @param condition Network condition. */ public void setIsMultiConexed(int condition) { isMultiConexed = condition; } //setIsMultiConexed() /** * Sets if the network is recurrent or not. * * @param condition Network condition. */ public void setIsRecurrent(int condition) { isRecurrent = condition; } //setIsRecurrent() /* (non-Javadoc) * @see neuralnetworktoolkit.INeuralNetwork#getStaticInputValues() */ public double[] getStaticInputValues() { return staticInputValues; } //getStaticInputValues() /* (non-Javadoc) * @see neuralnetworktoolkit.INeuralNetwork#updateWeights(double[]) */ public void updateWeights(double[][] increment) { int firstLayer; // TODO Erase comented instrumentation. switch (isDynamic) { case NeuralNetwork.NOT_DYNAMIC : { switch (isMultiConexed) { case NeuralNetwork.MULTICONEXED : { firstLayer = 0; int index = 0; for (int i = (networkSize - 1); i >= firstLayer; i--) { for (int j = 0; j < getLayer(i).getLayerSize(); j++) { // Calculates the respective weight times delta of the forward layer. getLayer(i).updateBias( increment[index][0], j); index++; for (int k = 0; k < getLayer(i).getWeightSize(j); k++) { //double x = increment getLayer(i).updateWeight( increment[index][0], k, j); index++; } // setar o delta } } } break; case NeuralNetwork.NOT_MULTICONEXED : { // TODO Implement this. } break; } } break; case NeuralNetwork.DYNAMIC : { switch (isMultiConexed) { case NeuralNetwork.MULTICONEXED : { // TODO Implement this. } break; case NeuralNetwork.NOT_MULTICONEXED : { // TODO Implement this. } break; } } break; } } //updateWeights() /** * Sets if the network is auto hidden or not. * * @param condition Network condition. */ public void setIsAutoHidden(int condition) { isAutoHidden = condition; } //setIsAutoHidden /** * Sets if the network have a normalizer layer or not. * * @param condition Network condition. */ public void setIsNeuronNormalizer(int condition) { isNeuronNormalizer = condition; } //setIsNeuronNormalizer() /** * Sets if the network receives numerical inputs or not. * * @param condition Network condition. */ public void setIsNumericalInputs(int condition) { isNumericalInputs = condition; } //setIsNumericalInputs() /** * Returns the input layer size. * * @return Input layer size. */ public int getInputSize() { return inputSize; } //getInputSize() /* (non-Javadoc) * @see neuralnetworktoolkit.INeuralNetwork#getNetworkSize() */ public int getNetworkSize() { return networkSize; } //getNetworkSize() /* (non-Javadoc) * @see neuralnetworktoolkit.INeuralNetwork#getOutputSize() */ public int getOutputSize() { return outputSize; } //getOutputSize() /** * Sets the input layer size. * * @param size Size to be seted. */ public void setInputSize(int size) { inputSize = size; } //setInputSize() /** * Sets the network size (number of layers). * * @param size Size to be seted. */ public void setNetworkSize(int size) { networkSize = size; } //setNetworkSize() /** * Sets the output layer size. * * @param size Size to be seted. */ public void setOutputSize(int size) { outputSize = size; } //setOutputSize() /** * Returns the network number of internal layers. * * @return Number of internal layers. */ public int getNumberOfInternalLayers() { return numberOfInternalLayers; } //getNumberOfInternalLayers() /** * Sets the network number of internal layers. * * @param number Number of internal layers. */ public void setNumberOfInternalLayers(int number) { numberOfInternalLayers = number; } //setNumberOfInternalLayers() /* (non-Javadoc) * @see neuralnetworktoolkit.INeuralNetwork#isNeuronNormalizer() */ /*public boolean isNeuronNormalizer() { boolean result = false; if (this.isNeuronNormalizer == NeuralNetwork.NEURON_NORMALIZER) result = true; return result; } //isNeuronNormalizer()*/ /* (non-Javadoc) * @see neuralnetworktoolkit.INeuralNetwork#isDynamic() */ public boolean isDynamic() { boolean result = false; if (this.isDynamic == NeuralNetwork.DYNAMIC) result = true; return result; } //isDynamic() /* (non-Javadoc) * @see neuralnetworktoolkit.INeuralNetwork#isMultiConexed() */ public boolean isMultiConexed() { boolean result = false; if (this.isMultiConexed == NeuralNetwork.MULTICONEXED) result = true; return result; } //isMultiConexed() /* (non-Javadoc) * @see neuralnetworktoolkit.INeuralNetwork#isRecurrent() */ public boolean isRecurrent() { boolean result = false; if (this.isRecurrent == NeuralNetwork.RECURRENT) result = true; return result; } //isRecurrent() /* (non-Javadoc) * @see neuralnetworktoolkit.INeuralNetwork#getError() */ public double getError() { return error; } //getError() /* (non-Javadoc) * @see neuralnetworktoolkit.INeuralNetwork#setError() */ public void setError(double error) { this.error = error; } //setError() } //NeuralNetwork
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -