testinputfunction.java

来自「神经网络源代码,实现了一个BP神经网络,可以完成基于BP的神经网络算法.」· Java 代码 · 共 30 行

JAVA
30
字号
package net.openai.ai.nn.input;import java.util.*;import net.openai.ai.nn.network.*;public class TestInputFunction extends InputFunction {    //  this method will get all the neurons connections and     //  calculate the input for this neuron.    public final void calculateInput(Neuron neuron) {	double input = 0;	boolean hasFromConnections = false;	Vector connections = neuron.getConnections();	int size = connections.size();	for(int i = 0; i < size; i++) {	    Connection connection = (Connection) connections.elementAt(i);	    if(!neuron.equals(connection.getToNeuron()))		continue;	    hasFromConnections = true;	    Neuron fromNeuron = connection.getFromNeuron();	    Weight weight = connection.getWeight();	    input += (fromNeuron.getOutput() * weight.getValue());	    //db("Upstream Output: " + fromNeuron.getOutput());	    //db("Weight value:    " + weight.getValue());	}	if(hasFromConnections)	    neuron.setInput(input);    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?