Java Code Examples for org.neuroph.util.NeuronProperties#setProperty()
The following examples show how to use
org.neuroph.util.NeuronProperties#setProperty() .
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 |
/** * * @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: Adaline.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates adaline network architecture with specified number of input neurons * * @param inputNeuronsCount * number of neurons in input layer */ private void createNetwork(int inputNeuronsCount) { // set network type code this.setNetworkType(NeuralNetworkType.ADALINE); // create input layer neuron settings for this network NeuronProperties inNeuronProperties = new NeuronProperties(); inNeuronProperties.setProperty("transferFunction", TransferFunctionType.LINEAR); // createLayer input layer with specified number of neurons //Layer inputLayer = LayerFactory.createLayer(inputNeuronsCount, inNeuronProperties); Layer inputLayer = new InputLayer(inputNeuronsCount); inputLayer.addNeuron(new BiasNeuron()); // add bias neuron (always 1, and it will act as bias input for output neuron) this.addLayer(inputLayer); // create output layer neuron settings for this network NeuronProperties outNeuronProperties = new NeuronProperties(); outNeuronProperties.setProperty("transferFunction", TransferFunctionType.LINEAR); // was RAMP // outNeuronProperties.setProperty("transferFunction.slope", new Double(1)); // outNeuronProperties.setProperty("transferFunction.yHigh", new Double(1)); // outNeuronProperties.setProperty("transferFunction.xHigh", new Double(1)); // outNeuronProperties.setProperty("transferFunction.yLow", new Double(-1)); // outNeuronProperties.setProperty("transferFunction.xLow", new Double(-1)); // createLayer output layer (only one neuron) Layer outputLayer = LayerFactory.createLayer(1, outNeuronProperties); this.addLayer(outputLayer); // createLayer full conectivity between input and output layer ConnectionFactory.fullConnect(inputLayer, outputLayer); // set input and output cells for network NeuralNetworkFactory.setDefaultIO(this); // set LMS learning rule for this network this.setLearningRule(new LMS()); }
Example 3
Source File: ART1Network.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** 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 4
Source File: MultiLayerPerceptron.java From NeurophFramework with Apache License 2.0 | 5 votes |
public MultiLayerPerceptron(List<Integer> neuronsInLayers, TransferFunctionType transferFunctionType) { // init neuron settings NeuronProperties neuronProperties = new NeuronProperties(); neuronProperties.setProperty("useBias", true); neuronProperties.setProperty("transferFunction", transferFunctionType); this.createNetwork(neuronsInLayers, neuronProperties); }
Example 5
Source File: MultiLayerPerceptron.java From NeurophFramework with Apache License 2.0 | 5 votes |
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 6
Source File: MultiLayerPerceptron.java From NeurophFramework with Apache License 2.0 | 5 votes |
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 7
Source File: MultiLayerPerceptron.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates new MultiLayerPerceptron with specified number of neurons in layers * * @param neuronsInLayers collection of neuron number in layers */ public MultiLayerPerceptron(List<Integer> neuronsInLayers) { // init neuron settings NeuronProperties neuronProperties = new NeuronProperties(); neuronProperties.setProperty("useBias", true); neuronProperties.setProperty("transferFunction", TransferFunctionType.SIGMOID); this.createNetwork(neuronsInLayers, neuronProperties); }
Example 8
Source File: MaxNet.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates MaxNet network architecture * * @param neuronNum * neuron number in network * @param neuronProperties * neuron properties */ private void createNetwork(int neuronsCount) { // set network type this.setNetworkType(NeuralNetworkType.MAXNET); // createLayer input layer in layer Layer inputLayer = LayerFactory.createLayer(neuronsCount, new NeuronProperties()); this.addLayer(inputLayer); // createLayer properties for neurons in output layer NeuronProperties neuronProperties = new NeuronProperties(); neuronProperties.setProperty("neuronType", CompetitiveNeuron.class); neuronProperties.setProperty("transferFunction", TransferFunctionType.RAMP); // createLayer full connectivity in competitive layer CompetitiveLayer competitiveLayer = new CompetitiveLayer(neuronsCount, neuronProperties); // add competitive layer to network this.addLayer(competitiveLayer); double competitiveWeight = -(1 / (double) neuronsCount); // createLayer full connectivity within competitive layer ConnectionFactory.fullConnect(competitiveLayer, competitiveWeight, 1); // createLayer forward connectivity from input to competitive layer ConnectionFactory.forwardConnect(inputLayer, competitiveLayer, 1); // set input and output cells for this network NeuralNetworkFactory.setDefaultIO(this); }
Example 9
Source File: Hopfield.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates new Hopfield network with specified neuron number * * @param neuronsCount * neurons number in Hopfied network */ public Hopfield(int neuronsCount) { // init neuron settings for hopfield network NeuronProperties neuronProperties = new NeuronProperties(); neuronProperties.setProperty("neuronType", InputOutputNeuron.class); neuronProperties.setProperty("bias", new Double(0)); neuronProperties.setProperty("transferFunction", TransferFunctionType.STEP); neuronProperties.setProperty("transferFunction.yHigh", new Double(1)); neuronProperties.setProperty("transferFunction.yLow", new Double(0)); this.createNetwork(neuronsCount, neuronProperties); }
Example 10
Source File: Instar.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates Instar architecture with specified number of input neurons * * @param inputNeuronsCount * number of neurons in input layer */ private void createNetwork(int inputNeuronsCount ) { // set network type this.setNetworkType(NeuralNetworkType.INSTAR); // init neuron settings for this type of network NeuronProperties neuronProperties = new NeuronProperties(); neuronProperties.setProperty("transferFunction", TransferFunctionType.STEP); // create input layer Layer inputLayer = LayerFactory.createLayer(inputNeuronsCount, neuronProperties); this.addLayer(inputLayer); // createLayer output layer neuronProperties.setProperty("transferFunction", TransferFunctionType.STEP); Layer outputLayer = LayerFactory.createLayer(1, neuronProperties); this.addLayer(outputLayer); // create full conectivity between input and output layer ConnectionFactory.fullConnect(inputLayer, outputLayer); // set input and output cells for this network NeuralNetworkFactory.setDefaultIO(this); // set appropriate learning rule for this network this.setLearningRule(new InstarLearning()); }
Example 11
Source File: Outstar.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates Outstar architecture with specified number of neurons in * output layer * * @param outputNeuronsCount * number of neurons in output layer */ private void createNetwork(int outputNeuronsCount ) { // set network type this.setNetworkType(NeuralNetworkType.OUTSTAR); // init neuron settings for this type of network NeuronProperties neuronProperties = new NeuronProperties(); neuronProperties.setProperty("transferFunction", TransferFunctionType.STEP); // create input layer Layer inputLayer = LayerFactory.createLayer(1, neuronProperties); this.addLayer(inputLayer); // createLayer output layer neuronProperties.setProperty("transferFunction", TransferFunctionType.RAMP); Layer outputLayer = LayerFactory.createLayer(outputNeuronsCount, neuronProperties); this.addLayer(outputLayer); // create full conectivity between input and output layer ConnectionFactory.fullConnect(inputLayer, outputLayer); // set input and output cells for this network NeuralNetworkFactory.setDefaultIO(this); // set outstar learning rule for this network this.setLearningRule(new OutstarLearning()); }
Example 12
Source File: SupervisedHebbianNetwork.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** *Creates an instance of Supervised Hebbian Network with specified number * of neurons in input layer, output layer and transfer function * * @param inputNeuronsNum * number of neurons in input layer * @param outputNeuronsNum * number of neurons in output layer * @param transferFunctionType * transfer function type */ private void createNetwork(int inputNeuronsNum, int outputNeuronsNum, TransferFunctionType transferFunctionType) { // init neuron properties NeuronProperties neuronProperties = new NeuronProperties(); neuronProperties.setProperty("transferFunction", transferFunctionType); neuronProperties.setProperty("transferFunction.slope", new Double(1)); neuronProperties.setProperty("transferFunction.yHigh", new Double(1)); neuronProperties.setProperty("transferFunction.xHigh", new Double(1)); neuronProperties.setProperty("transferFunction.yLow", new Double(-1)); neuronProperties.setProperty("transferFunction.xLow", new Double(-1)); // set network type code this.setNetworkType(NeuralNetworkType.SUPERVISED_HEBBIAN_NET); // createLayer input layer Layer inputLayer = LayerFactory.createLayer(inputNeuronsNum, neuronProperties); this.addLayer(inputLayer); // createLayer output layer Layer outputLayer = LayerFactory.createLayer(outputNeuronsNum, neuronProperties); this.addLayer(outputLayer); // createLayer full conectivity between input and output layer ConnectionFactory.fullConnect(inputLayer, outputLayer); // set input and output cells for this network NeuralNetworkFactory.setDefaultIO(this); // set appropriate learning rule for this network this.setLearningRule(new SupervisedHebbianLearning()); }
Example 13
Source File: BAM.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates an instance of BAM network with specified number of neurons * in input and output layers. * * @param inputNeuronsCount * number of neurons in input layer * @param outputNeuronsCount * number of neurons in output layer */ public BAM(int inputNeuronsCount, int outputNeuronsCount) { // init neuron settings for BAM network NeuronProperties neuronProperties = new NeuronProperties(); neuronProperties.setProperty("neuronType", InputOutputNeuron.class); neuronProperties.setProperty("bias", new Double(0)); neuronProperties.setProperty("transferFunction", TransferFunctionType.STEP); neuronProperties.setProperty("transferFunction.yHigh", new Double(1)); neuronProperties.setProperty("transferFunction.yLow", new Double(0)); this.createNetwork(inputNeuronsCount, outputNeuronsCount, neuronProperties); }
Example 14
Source File: Perceptron.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates perceptron architecture with specified number of neurons in input * and output layer, specified transfer function * * @param inputNeuronsCount * number of neurons in input layer * @param outputNeuronsCount * number of neurons in output layer * @param transferFunctionType * neuron transfer function type */ private void createNetwork(int inputNeuronsCount, int outputNeuronsCount, TransferFunctionType transferFunctionType) { // set network type this.setNetworkType(NeuralNetworkType.PERCEPTRON); Layer inputLayer = new InputLayer(inputNeuronsCount); this.addLayer(inputLayer); NeuronProperties outputNeuronProperties = new NeuronProperties(); outputNeuronProperties.setProperty("neuronType", ThresholdNeuron.class); outputNeuronProperties.setProperty("thresh", new Double(Math.abs(Math.random()))); outputNeuronProperties.setProperty("transferFunction", transferFunctionType); // for sigmoid and tanh transfer functions set slope propery outputNeuronProperties.setProperty("transferFunction.slope", new Double(1)); // createLayer output layer Layer outputLayer = LayerFactory.createLayer(outputNeuronsCount, outputNeuronProperties); this.addLayer(outputLayer); // create full conectivity between input and output layer ConnectionFactory.fullConnect(inputLayer, outputLayer); // set input and output cells for this network NeuralNetworkFactory.setDefaultIO(this); this.setLearningRule(new BinaryDeltaRule()); // set appropriate learning rule for this network // if (transferFunctionType == TransferFunctionType.STEP) { // this.setLearningRule(new BinaryDeltaRule(this)); // } else if (transferFunctionType == TransferFunctionType.SIGMOID) { // this.setLearningRule(new SigmoidDeltaRule(this)); // } else if (transferFunctionType == TransferFunctionType.TANH) { // this.setLearningRule(new SigmoidDeltaRule(this)); // } else { // this.setLearningRule(new PerceptronLearning(this)); // } }
Example 15
Source File: UnsupervisedHebbianNetwork.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates an instance of Unsuervised Hebian net with specified number * of neurons in input layer and output layer, and transfer function * * @param inputNeuronsNum * number of neurons in input layer * @param outputNeuronsNum * number of neurons in output layer * @param transferFunctionType * transfer function type */ private void createNetwork(int inputNeuronsNum, int outputNeuronsNum, TransferFunctionType transferFunctionType) { // init neuron properties NeuronProperties neuronProperties = new NeuronProperties(); // neuronProperties.setProperty("bias", new Double(-Math // .abs(Math.random() - 0.5))); // Hebbian network cann not work // without bias neuronProperties.setProperty("transferFunction", transferFunctionType); neuronProperties.setProperty("transferFunction.slope", new Double(1)); // set network type code this.setNetworkType(NeuralNetworkType.UNSUPERVISED_HEBBIAN_NET); // createLayer input layer Layer inputLayer = LayerFactory.createLayer(inputNeuronsNum, neuronProperties); this.addLayer(inputLayer); // createLayer output layer Layer outputLayer = LayerFactory.createLayer(outputNeuronsNum, neuronProperties); this.addLayer(outputLayer); // createLayer full conectivity between input and output layer ConnectionFactory.fullConnect(inputLayer, outputLayer); // set input and output cells for this network NeuralNetworkFactory.setDefaultIO(this); // set appropriate learning rule for this network this.setLearningRule(new UnsupervisedHebbianLearning()); //this.setLearningRule(new OjaLearning(this)); }
Example 16
Source File: CompetitiveNetwork.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * 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 17
Source File: RecommenderNetwork.java From NeurophFramework with Apache License 2.0 | 4 votes |
public void createDemoNetwork() { int productsCount = 20; int typesCount = 3; int brandsCount = 3; int priceCount = 3; int promoCount = 3; this.setNetworkType(NeuralNetworkType.RECOMMENDER); //this.getLayers().clear(); // init neuron settings for this type of network NeuronProperties neuronProperties = new NeuronProperties(); neuronProperties.setProperty("transferFunction", TransferFunctionType.RAMP); // for sigmoid and tanh transfer functions neuronProperties.setProperty("transferFunction.slope", new Double(1)); // create input layer Layer inputLayer = LayerFactory.createLayer(productsCount, neuronProperties); this.addLayer(inputLayer); createProductLabels(inputLayer); // create product types layer Layer typeLayer = LayerFactory.createLayer(typesCount, neuronProperties); createTypeLabels(typeLayer); this.addLayer(typeLayer); // create brands layer Layer brandLayer = LayerFactory.createLayer(brandsCount, neuronProperties); createBrandLabels(brandLayer); this.addLayer(brandLayer); // create price layer Layer priceLayer = LayerFactory.createLayer(priceCount, neuronProperties); createPriceLabels(priceLayer); this.addLayer(priceLayer); // create price layer Layer promoLayer = LayerFactory.createLayer(promoCount, neuronProperties); createPromoLabels(promoLayer); this.addLayer(promoLayer); // create output layer Layer outputLayer = LayerFactory.createLayer(productsCount, neuronProperties); this.addLayer(outputLayer); createProductLabels(outputLayer); createTypeConnections(); createBrandConnections(); createPriceConnections(); createPromoConnections(); // create reccurent self connections in output layer for(Neuron neuron : this.getLayerAt(outputLayerIdx).getNeurons()) { neuron.addInputConnection(neuron, 1); } // set input and output cells for this network NeuralNetworkFactory.setDefaultIO(this); // dont learn the self connections // moze cak i posle svakog prolaza da se primenjuje hebbianovo pravilo a ne samo nakon kupovine // napravi vise varijanti // ako kupuje onda moze da se primenjje winner takes all hebbian learning this.setLearningRule(new UnsupervisedHebbianLearning()); }
Example 18
Source File: JordanNetwork.java From NeurophFramework with Apache License 2.0 | 3 votes |
private void createNetwork(int inputNeuronsCount, int hiddenNeuronsCount, int contextNeuronsCount, int outputNeuronsCount) { // create input layer InputLayer inputLayer = new InputLayer(inputNeuronsCount); inputLayer.addNeuron(new BiasNeuron()); addLayer(inputLayer); NeuronProperties neuronProperties = new NeuronProperties(); // neuronProperties.setProperty("useBias", true); neuronProperties.setProperty("transferFunction", TransferFunctionType.SIGMOID); // use linear or logitic function! (TR-8604.pdf) Layer hiddenLayer = new Layer(hiddenNeuronsCount, neuronProperties); hiddenLayer.addNeuron(new BiasNeuron()); addLayer(hiddenLayer); ConnectionFactory.fullConnect(inputLayer, hiddenLayer); Layer contextLayer = new Layer(contextNeuronsCount, neuronProperties); addLayer(contextLayer); // we might also need bias for context neurons? Layer outputLayer = new Layer(outputNeuronsCount, neuronProperties); addLayer(outputLayer); ConnectionFactory.fullConnect(hiddenLayer, outputLayer); ConnectionFactory.fullConnect(outputLayer, contextLayer); ConnectionFactory.fullConnect(contextLayer, hiddenLayer); // set input and output cells for network NeuralNetworkFactory.setDefaultIO(this); // set learnng rule this.setLearningRule(new BackPropagation()); }
Example 19
Source File: ElmanNetwork.java From NeurophFramework with Apache License 2.0 | 3 votes |
private void createNetwork(int inputNeuronsCount, int hiddenNeuronsCount, int contextNeuronsCount, int outputNeuronsCount) { // create input layer InputLayer inputLayer = new InputLayer(inputNeuronsCount); inputLayer.addNeuron(new BiasNeuron()); addLayer(inputLayer); NeuronProperties neuronProperties = new NeuronProperties(); // neuronProperties.setProperty("useBias", true); neuronProperties.setProperty("transferFunction", TransferFunctionType.SIGMOID); Layer hiddenLayer = new Layer(hiddenNeuronsCount, neuronProperties); hiddenLayer.addNeuron(new BiasNeuron()); addLayer(hiddenLayer); ConnectionFactory.fullConnect(inputLayer, hiddenLayer); Layer contextLayer = new Layer(contextNeuronsCount, neuronProperties); addLayer(contextLayer); // we might also need bias for context neurons? Layer outputLayer = new Layer(outputNeuronsCount, neuronProperties); addLayer(outputLayer); ConnectionFactory.fullConnect(hiddenLayer, outputLayer); ConnectionFactory.forwardConnect(hiddenLayer, contextLayer); // forward or full connectivity? ConnectionFactory.fullConnect(contextLayer, hiddenLayer); // set input and output cells for network NeuralNetworkFactory.setDefaultIO(this); // set learnng rule this.setLearningRule(new BackPropagation()); }