org.neuroph.core.input.WeightedSum Java Examples

The following examples show how to use org.neuroph.core.input.WeightedSum. 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: ART1Network.java    From NeurophFramework with Apache License 2.0 6 votes vote down vote up
/**
    *
    * @param vigilance
    * @param L
    * @param neuronsInLayers
    */
   public ART1Network (double vigilance, int L, int ... neuronsInLayers) {
	// init neuron settings


	NeuronProperties neuronProperties = new NeuronProperties();
               neuronProperties.setProperty("useBias", true);
	neuronProperties.setProperty("transferFunction",
			TransferFunctionType.SIGMOID);
               neuronProperties.setProperty("inputFunction", WeightedSum.class);

               // Makes a vector, which gives as an array of numbers of neurons in each layer

	List<Integer> neuronsInLayersVector = new ArrayList<>();
	for(int i=0; i<neuronsInLayers.length; i++) {
                   neuronsInLayersVector.add(new Integer(neuronsInLayers[i]));
               }

	this.createNetwork(neuronsInLayersVector, neuronProperties, vigilance, L);
}
 
Example #2
Source File: CompetitiveNetwork.java    From NeurophFramework with Apache License 2.0 5 votes vote down vote up
/**
 * Creates Competitive network architecture
 * 
 * @param inputNeuronsCount
 *            input neurons number
        * @param outputNeuronsCount
        *            output neurons number
 * @param neuronProperties
 *            neuron properties
 */
private void createNetwork(int inputNeuronsCount, int outputNeuronsCount) {
	// set network type
	this.setNetworkType(NeuralNetworkType.COMPETITIVE);

	// createLayer input layer
	Layer inputLayer = LayerFactory.createLayer(inputNeuronsCount, new NeuronProperties());
	this.addLayer(inputLayer);

	// createLayer properties for neurons in output layer
	NeuronProperties neuronProperties = new NeuronProperties();
	neuronProperties.setProperty("neuronType", CompetitiveNeuron.class);
	neuronProperties.setProperty("inputFunction",	WeightedSum.class);
	neuronProperties.setProperty("transferFunction",TransferFunctionType.RAMP);

	// createLayer full connectivity in competitive layer
	CompetitiveLayer competitiveLayer = new CompetitiveLayer(outputNeuronsCount, neuronProperties);

	// add competitive layer to network
	this.addLayer(competitiveLayer);

	double competitiveWeight = -(1 / (double) outputNeuronsCount);
	// createLayer full connectivity within competitive layer
	ConnectionFactory.fullConnect(competitiveLayer, competitiveWeight, 1);

	// createLayer full connectivity from input to competitive layer
	ConnectionFactory.fullConnect(inputLayer, competitiveLayer);

	// set input and output cells for this network
	NeuralNetworkFactory.setDefaultIO(this);

	this.setLearningRule(new CompetitiveLearning());
}
 
Example #3
Source File: MultiLayerPerceptron.java    From NeurophFramework with Apache License 2.0 5 votes vote down vote up
public MultiLayerPerceptron(int... neuronsInLayers) {
    // init neuron settings
    NeuronProperties neuronProperties = new NeuronProperties();
    neuronProperties.setProperty("useBias", true);
    neuronProperties.setProperty("transferFunction", TransferFunctionType.SIGMOID);
    neuronProperties.setProperty("inputFunction", WeightedSum.class);

    List<Integer> neuronsInLayersVector = new ArrayList<>();
    for (int i = 0; i < neuronsInLayers.length; i++) {
        neuronsInLayersVector.add(Integer.valueOf(neuronsInLayers[i]));
    }

    this.createNetwork(neuronsInLayersVector, neuronProperties);
}
 
Example #4
Source File: MultiLayerPerceptron.java    From NeurophFramework with Apache License 2.0 5 votes vote down vote up
public MultiLayerPerceptron(TransferFunctionType transferFunctionType, int... neuronsInLayers) {
    // init neuron settings
    NeuronProperties neuronProperties = new NeuronProperties();
    neuronProperties.setProperty("useBias", true);
    neuronProperties.setProperty("transferFunction", transferFunctionType);
    neuronProperties.setProperty("inputFunction", WeightedSum.class);


    List<Integer> neuronsInLayersVector = new ArrayList<>();
    for (int i = 0; i < neuronsInLayers.length; i++) {
        neuronsInLayersVector.add(Integer.valueOf(neuronsInLayers[i]));
    }

    this.createNetwork(neuronsInLayersVector, neuronProperties);
}
 
Example #5
Source File: NeuronProperties.java    From NeurophFramework with Apache License 2.0 5 votes vote down vote up
public NeuronProperties(TransferFunctionType transferFunctionType, boolean useBias) {
    initKeys();
    this.setProperty(INPUT_FUNCTION, WeightedSum.class);
    this.setProperty(TRANSFER_FUNCTION, transferFunctionType.getTypeClass());
    this.setProperty(USE_BIAS, useBias); // ovo bi trebalo da je defaultno podesavanje uvek na tru, ako nece moze da se stavi na 0
    this.setProperty(NEURON_TYPE, Neuron.class);
}
 
Example #6
Source File: Neuron.java    From NeurophFramework with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance of Neuron with default settings: weighted sum input
 * function and Step transfer function. This is the basic McCulloch-Pitts
 * neuron model.
 */
public Neuron() {
    this.inputFunction = new WeightedSum();
    this.transferFunction = new Step();
    this.inputConnections = new ArrayList<>();
    this.outConnections = new ArrayList<>();
}
 
Example #7
Source File: ART1Network.java    From NeurophFramework with Apache License 2.0 5 votes vote down vote up
/** Creates new ART1 Network, with specified number of neurons in layers
  *   and a vigilance parameter
  *
  *  @param neuronsInLayers
  *            collection of neuron number in layers
   * @param vigilance
   * @param L
  *
  */

  public ART1Network (List<Integer> neuronsInLayers, double vigilance, int L ) {

NeuronProperties neuronProperties = new NeuronProperties();
              neuronProperties.setProperty("useBias", true);
neuronProperties.setProperty("transferFunction", TransferFunctionType.SIGMOID);
              neuronProperties.setProperty("inputFunction", new WeightedSum());

this.createNetwork(neuronsInLayers, neuronProperties, vigilance, L);
  }
 
Example #8
Source File: Model.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public NeuralNetwork<MomentumBackpropagation> createNeuralNetwork(Integer inValueCount, Integer outValueCount,
		Integer hiddenLayerCount) {
	NeuronProperties inputNeuronProperties = new NeuronProperties(InputNeuron.class, Linear.class);
	NeuronProperties hiddenNeuronProperties = new NeuronProperties(InputOutputNeuron.class, WeightedSum.class,
			Sigmoid.class);
	NeuronProperties outputNeuronProperties = new NeuronProperties(InputOutputNeuron.class, WeightedSum.class,
			Sigmoid.class);
	NeuralNetwork<MomentumBackpropagation> neuralNetwork = new NeuralNetwork<>();
	neuralNetwork.setNetworkType(NeuralNetworkType.MULTI_LAYER_PERCEPTRON);
	Layer inputLayer = LayerFactory.createLayer(inValueCount, inputNeuronProperties);
	inputLayer.addNeuron(new BiasNeuron());
	neuralNetwork.addLayer(inputLayer);
	List<Integer> hiddenNeurons = this.hiddenNeurons(inValueCount, outValueCount, hiddenLayerCount);
	for (Integer count : hiddenNeurons) {
		Layer layer = LayerFactory.createLayer(count, hiddenNeuronProperties);
		layer.addNeuron(new BiasNeuron());
		neuralNetwork.addLayer(layer);
	}
	Layer outputLayer = LayerFactory.createLayer(outValueCount, outputNeuronProperties);
	neuralNetwork.addLayer(outputLayer);
	for (int i = 0; i < (neuralNetwork.getLayersCount() - 1); i++) {
		Layer prevLayer = neuralNetwork.getLayers().get(i);
		Layer nextLayer = neuralNetwork.getLayers().get(i + 1);
		ConnectionFactory.fullConnect(prevLayer, nextLayer);
	}
	neuralNetwork.setLearningRule(this.createMomentumBackpropagation(
			MapTools.getDouble(this.getPropertyMap(), PROPERTY_MLP_MAXERROR, DEFAULT_MLP_MAXERROR),
			MapTools.getInteger(this.getPropertyMap(), PROPERTY_MLP_MAXITERATION, DEFAULT_MLP_MAXITERATION),
			MapTools.getDouble(this.getPropertyMap(), PROPERTY_MLP_LEARNINGRATE, DEFAULT_MLP_LEARNINGRATE),
			MapTools.getDouble(this.getPropertyMap(), PROPERTY_MLP_MOMENTUM, DEFAULT_MLP_MOMENTUM)));
	NeuralNetworkFactory.setDefaultIO(neuralNetwork);
	neuralNetwork.randomizeWeights();
	return neuralNetwork;
}
 
Example #9
Source File: InputNeuron.java    From NeurophFramework with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new instance of InputNeuron with linear transfer function
 */
public InputNeuron() {
    super(new WeightedSum(), new Linear());
}
 
Example #10
Source File: NeuronProperties.java    From NeurophFramework with Apache License 2.0 4 votes vote down vote up
public NeuronProperties() {
    initKeys();
    this.setProperty(INPUT_FUNCTION, WeightedSum.class);
    this.setProperty(TRANSFER_FUNCTION, Linear.class);
    this.setProperty(NEURON_TYPE, Neuron.class);
}
 
Example #11
Source File: NeuronProperties.java    From NeurophFramework with Apache License 2.0 4 votes vote down vote up
public NeuronProperties(Class<? extends Neuron> neuronClass) {
    initKeys();
    this.setProperty(INPUT_FUNCTION, WeightedSum.class);
    this.setProperty(TRANSFER_FUNCTION, Linear.class);
    this.setProperty(NEURON_TYPE, neuronClass);
}
 
Example #12
Source File: NeuronProperties.java    From NeurophFramework with Apache License 2.0 4 votes vote down vote up
public NeuronProperties(Class<? extends Neuron> neuronClass, Class<? extends TransferFunction> transferFunctionClass) {
    initKeys();
    this.setProperty(INPUT_FUNCTION, WeightedSum.class);
    this.setProperty(TRANSFER_FUNCTION, transferFunctionClass);
    this.setProperty(NEURON_TYPE, neuronClass);
}
 
Example #13
Source File: NeuronProperties.java    From NeurophFramework with Apache License 2.0 4 votes vote down vote up
public NeuronProperties(Class<? extends Neuron> neuronClass, TransferFunctionType transferFunctionType) {
    initKeys();
    this.setProperty(INPUT_FUNCTION, WeightedSum.class);
    this.setProperty(TRANSFER_FUNCTION, transferFunctionType.getTypeClass());
    this.setProperty(NEURON_TYPE, neuronClass);
}