⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testarchitecture.java

📁 神经网络源代码,实现了一个BP神经网络,可以完成基于BP的神经网络算法.
💻 JAVA
字号:
package net.openai.ai.nn.architecture;import java.util.*;import net.openai.ai.nn.network.*;/** *  This class defines how the neural network will be constructed  *  or connected.  How each neuron will be connected to other neurons  *  in the network. * */public class TestArchitecture extends Architecture {    public TestArchitecture() {	    }    /**     * Connects the network passed in to this method.     * @param network The network to be connected.     */    public final void connectNetwork(Network network) {	//  get all the layers	Vector layers = network.getLayers();	//  get the number of layers	int layerSize = layers.size();	//  for each layer	for(int i = 0; i < layerSize; i++) {	    //  see if this is the last layer, if so we're done	    if(i == (layerSize - 1))		return;	    	    //  get the 'from' layer	    Layer fromLayer = (Layer) layers.elementAt(i);	    //  get the neurons for this layer	    Vector fromNeurons = (Vector) fromLayer.getNeurons();	    //  make sure the layer has neurons	    if(fromNeurons == null || fromNeurons.isEmpty())		return;	    //  get the size	    int fromNeuronsSize = fromNeurons.size();	    	    //  get the 'to' layer	    Layer toLayer = (Layer) layers.elementAt(i + 1);	    //  get the neurons for this layer	    Vector toNeurons = (Vector) toLayer.getNeurons();	    //  make sure the layer has neurons	    if(toNeurons == null || toNeurons.isEmpty())		return;	    //  get the size	    int toNeuronsSize = toNeurons.size();	    //  connect the network	    for(int j = 0; j < fromNeuronsSize; j++) {		for(int k = 0; k < toNeuronsSize; k++) {		    //  get the 'from' neuron 		    Neuron fromNeuron = (Neuron) fromNeurons.elementAt(j);		    //  get the 'to' neuron		    Neuron toNeuron = (Neuron) toNeurons.elementAt(k);		    if(toNeuron instanceof BiasNeuron)			continue;		    //  create the connection		    Connection connection = new Connection();		    //  add the connection to the 'from' neuron		    fromNeuron.addConnectionFrom(connection);		    //  add the connection to the 'to' neuron		    toNeuron.addConnectionTo(connection);		}	    }	}	return;    }    /**     * Iterates the network according to the rules set by the architecture.     * @param network The network to be iterated.     */    public final void iterateNetwork(Network network) {    }    private void db(String s) {	System.err.println("TestArchitecture: " + s);    }} 

⌨️ 快捷键说明

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