Java Code Examples for org.neuroph.core.Layer#getNeuronsCount()

The following examples show how to use org.neuroph.core.Layer#getNeuronsCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KohonenLearning.java    From NeurophFramework with Apache License 2.0 6 votes vote down vote up
private void learnPattern(DataSetRow dataSetRow, int neighborhood) {
	neuralNetwork.setInput(dataSetRow.getInput());
	neuralNetwork.calculate();
	Neuron winner = getClosestNeuron();
	if (winner.getOutput() == 0)
		return; // ako je vec istrenirana jedna celija, izadji

	Layer mapLayer = neuralNetwork.getLayerAt(1);
	int winnerIdx = mapLayer.indexOf(winner);
	adjustCellWeights(winner, 0);

	int cellNum = mapLayer.getNeuronsCount();
	for (int p = 0; p < cellNum; p++) {
		if (p == winnerIdx)
			continue;
		if (isNeighbor(winnerIdx, p, neighborhood)) {
			Neuron cell = mapLayer.getNeuronAt(p);
			adjustCellWeights(cell, 1);
		} // if
	} // for

}
 
Example 2
Source File: MatrixMlpLayer.java    From NeurophFramework with Apache License 2.0 6 votes vote down vote up
public MatrixMlpLayer(Layer sourceLayer, MatrixLayer previousLayer, TransferFunction transferFunction) {
          this.sourceLayer = sourceLayer;
          this.previousLayer = previousLayer;
          if (!(previousLayer instanceof MatrixInputLayer)) ((MatrixMlpLayer)previousLayer).setNextLayer(this);
          this.transferFunction = transferFunction;

          this.neuronsCount = sourceLayer.getNeuronsCount();
//          if (sourceLayer.getNeuronAt(neuronsCount-1) instanceof BiasNeuron) this.neuronsCount = this.neuronsCount -1;

          this.inputsCount = previousLayer.getOutputs().length;

          outputs = new double[neuronsCount];
//          biases = new double[neuronsCount];
//          deltaBiases = new double[neuronsCount];
          inputs = new double[inputsCount];
          netInput = new double[neuronsCount];
          weights = new double[neuronsCount][inputsCount];
          deltaWeights = new double[neuronsCount][inputsCount];

          errors = new double[neuronsCount];

          copyNeuronsToMatrices();
      }
 
Example 3
Source File: ConnectionFactory.java    From NeurophFramework with Apache License 2.0 5 votes vote down vote up
/**
 * Creates full connectivity within layer - each neuron with all other
 * within the same layer
 */
public static void fullConnect(Layer layer) {
	int neuronNum = layer.getNeuronsCount();
	for (int i = 0; i < neuronNum; i++) {
		for (int j = 0; j < neuronNum; j++) {
			if (j == i)
				continue;
			Neuron from = layer.getNeuronAt(i);
			Neuron to = layer.getNeuronAt(j);
			createConnection(from, to);
		} // j
	} // i
}
 
Example 4
Source File: ConnectionFactory.java    From NeurophFramework with Apache License 2.0 5 votes vote down vote up
/**
 * Creates full connectivity within layer - each neuron with all other
 * within the same layer with the specified weight values for all
 * conections.
 */
public static void fullConnect(Layer layer, double weightVal) {
	int neuronNum = layer.getNeuronsCount();
	for (int i = 0; i < neuronNum; i++) {
		for (int j = 0; j < neuronNum; j++) {
			if (j == i)
				continue;
			Neuron from = layer.getNeuronAt(i);
			Neuron to = layer.getNeuronAt(j);
			createConnection(from, to, weightVal);
		} // j
	} // i
}
 
Example 5
Source File: ConnectionFactory.java    From NeurophFramework with Apache License 2.0 5 votes vote down vote up
/**
 * Creates full connectivity within layer - each neuron with all other
 * within the same layer with the specified weight and delay values for all
 * conections.
 */
public static void fullConnect(Layer layer, double weightVal, int delay) {
	int neuronNum = layer.getNeuronsCount();
	for (int i = 0; i < neuronNum; i++) {
		for (int j = 0; j < neuronNum; j++) {
			if (j == i)
				continue;
			Neuron from = layer.getNeuronAt(i);
			Neuron to = layer.getNeuronAt(j);
			createConnection(from, to, weightVal, delay);
		} // j
	} // i
}
 
Example 6
Source File: ConnectionFactory.java    From NeurophFramework with Apache License 2.0 3 votes vote down vote up
/**
 * Creates forward connectivity pattern between the specified layers
 * 
 * @param fromLayer
 *            layer to connect
 * @param toLayer
 *            layer to connect to
 */
public static void forwardConnect(Layer fromLayer, Layer toLayer, double weightVal) {
	for(int i=0; i<fromLayer.getNeuronsCount(); i++) {
		Neuron fromNeuron = fromLayer.getNeuronAt(i);
		Neuron toNeuron = toLayer.getNeuronAt(i);
		createConnection(fromNeuron, toNeuron, weightVal);
	}
}
 
Example 7
Source File: ConnectionFactory.java    From NeurophFramework with Apache License 2.0 3 votes vote down vote up
/**
 * Creates forward connection pattern between specified layers
 * 
 * @param fromLayer
 *            layer to connect
 * @param toLayer
 *            layer to connect to
 */
public static void forwardConnect(Layer fromLayer, Layer toLayer) {
	for(int i=0; i<fromLayer.getNeuronsCount(); i++) {
		Neuron fromNeuron = fromLayer.getNeuronAt(i);
		Neuron toNeuron = toLayer.getNeuronAt(i);
		createConnection(fromNeuron, toNeuron, 1);
	}		
}