org.neuroph.util.NeuronProperties Java Examples
The following examples show how to use
org.neuroph.util.NeuronProperties.
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: MlpNetworkTrainer.java From developerWorks with Apache License 2.0 | 6 votes |
/** * Create the {@link NetworkMetrics} object. It is used to keep track of information about * the networks produced by this run. * * @param yearsToSimulate * The years for which simulations are to be run against the trained * networks produced by the program to validate them. * * @param neuronLayerDescriptor * The network descriptor, each Integer in the array represents * the number of neurons in that layer. The 0th element represents the input layer, the last element * represents the output layer, with hidden layers between them. * * @param neuronProperties * The {@link NeuronProperties} Neuroph metadata object. Used when creating * a new network as a convenient way to set a bunch of properties all at once. * * @return {@link NetworkMetrics} - the metrics object. */ private NetworkMetrics createNetworkMetrics(MultiLayerPerceptron network, Integer[] yearsToSimulate, List<Integer> neuronLayerDescriptor, NeuronProperties neuronProperties) { String neuronLayerDescriptorString = NetworkUtils.generateLayerStructureString(neuronLayerDescriptor); // // Create metrics log.info("*********** FETCHING NETWORK METRICS **************"); NetworkMetrics metrics = networkMetricsCache.get(network); if (metrics == null) { log.info("*********** CREATED NEW NETWORK METRICS FOR THIS NETWORK (" + neuronLayerDescriptorString + ") **************"); metrics = new NetworkMetrics(); networkMetricsCache.put(network, metrics); } metrics.setNeuronProperties(neuronProperties); metrics.setIterationStartTime(System.currentTimeMillis()); metrics.setLearnStartTime(System.currentTimeMillis()); metrics.setLayerStructure(neuronLayerDescriptorString); metrics.setNumberOfIterationsSoFar(metrics.getNumberOfIterationsSoFar() + 1); metrics.setSimulationYears(yearsToSimulate); return metrics; }
Example #2
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 #3
Source File: Hopfield.java From NeurophFramework with Apache License 2.0 | 6 votes |
/** * Creates Hopfield network architecture * * @param neuronsCount * neurons number in Hopfied network * @param neuronProperties * neuron properties */ private void createNetwork(int neuronsCount, NeuronProperties neuronProperties) { // set network type this.setNetworkType(NeuralNetworkType.HOPFIELD); // createLayer neurons in layer Layer layer = LayerFactory.createLayer(neuronsCount, neuronProperties); // createLayer full connectivity in layer ConnectionFactory.fullConnect(layer, 0.1); // add layer to network this.addLayer(layer); // set input and output cells for this network NeuralNetworkFactory.setDefaultIO(this); // set Hopfield learning rule for this network //this.setLearningRule(new HopfieldLearning(this)); this.setLearningRule(new BinaryHebbianLearning()); }
Example #4
Source File: MlpNetworkTrainer.java From developerWorks with Apache License 2.0 | 6 votes |
/** * Yet another method to log network info. I probably should combine all these at * some point. * * @param metrics * The ubiquitous {@link NetworkMetrics} object. * @param neuronProperties * The Neuroph neuron properties metadata object * @param learningRule * The learning rule in use */ private static void logNetworkInfo(NetworkMetrics metrics, NeuronProperties neuronProperties, MomentumBackpropagation learningRule) { StringBuilder sb; String useBias = neuronProperties.getProperty("useBias").toString(); String learningRate = Double.toString(learningRule.getLearningRate()); String maxError = Double.toString(learningRule.getMaxError()); String momentum = Double.toString(learningRule.getMomentum()); log.info("*** NETWORK INFO ***"); sb = new StringBuilder(); sb.append("Network Info:\n"); sb.append("\tUse Bias : " + useBias + "\n"); sb.append("\tLearning Rate : " + learningRate + "\n"); sb.append("\tMax Error : " + maxError + "\n"); sb.append("\tMomentum : " + momentum + "\n"); sb.append("\tLayer Structure : " + metrics.getLayerStructure() + "\n"); sb.append("\tTotal Network Error : " + BigDecimal.valueOf(learningRule.getTotalNetworkError() * 100.0).setScale(2, RoundingMode.HALF_UP)); log.info(sb.toString()); }
Example #5
Source File: FeatureMapTest.java From NeurophFramework with Apache License 2.0 | 6 votes |
@Ignore public void testFeatureMapWithManyNeurons() { Dimension2D dimension = new Dimension2D(4, 3); FeatureMapLayer featureMap = new FeatureMapLayer(dimension, new NeuronProperties()); InputNeuron inputNeuron1 = new InputNeuron(); inputNeuron1.setInput(1); InputNeuron inputNeuron2 = new InputNeuron(); inputNeuron2.setInput(2); InputNeuron inputNeuron3 = new InputNeuron(); inputNeuron3.setInput(3); InputNeuron inputNeuron4 = new InputNeuron(); inputNeuron4.setInput(4); featureMap.addNeuron(inputNeuron1); featureMap.addNeuron(inputNeuron2); featureMap.addNeuron(inputNeuron3); featureMap.addNeuron(inputNeuron4); Assert.assertEquals(4, featureMap.getNeuronsCount()); }
Example #6
Source File: FeatureMapTest.java From NeurophFramework with Apache License 2.0 | 5 votes |
@Test public void testEmptyFeatureMap() { Dimension2D dimension = new Dimension2D(0, 0); FeatureMapLayer featureMap = new FeatureMapLayer(dimension, new NeuronProperties()); Assert.assertEquals(0, featureMap.getNeuronsCount()); Assert.assertEquals(0, featureMap.getHeight()); Assert.assertEquals(0, featureMap.getWidth()); }
Example #7
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 #8
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 #9
Source File: Model.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
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 #10
Source File: FeatureMapTest.java From NeurophFramework with Apache License 2.0 | 5 votes |
@Ignore public void testFeatureMapWithOneNeuron() { Dimension2D dimension = new Dimension2D(4, 3); FeatureMapLayer featureMap = new FeatureMapLayer(dimension, new NeuronProperties()); InputNeuron inputNeuron = new InputNeuron(); inputNeuron.setInput(1); featureMap.addNeuron(inputNeuron); Assert.assertEquals(1, featureMap.getNeuronsCount()); Assert.assertEquals(dimension.getWidth(), featureMap.getWidth()); Assert.assertEquals(dimension.getHeight(), featureMap.getHeight()); }
Example #11
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 #12
Source File: PoolingLayer.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates pooling layer with specified kernel, appropriate map * dimensions in regard to previous layer (fromLayer param) and specified * number of feature maps with given neuron properties. * * @param fromLayer previous layer, which will be connected to this layer * @param kernel kernel for all feature maps * @param numberOfMaps number of feature maps to create in this layer * @param neuronProp settings for neurons in feature maps */ public PoolingLayer(FeatureMapsLayer fromLayer, Dimension2D kernelDim, int numberOfMaps, NeuronProperties neuronProp) { this.kernel = kernel; Dimension2D fromDimension = fromLayer.getMapDimensions(); int mapWidth = fromDimension.getWidth() / kernel.getWidth(); int mapHeight = fromDimension.getHeight() / kernel.getHeight(); this.mapDimensions = new Dimension2D(mapWidth, mapHeight); createFeatureMaps(numberOfMaps, mapDimensions, kernelDim, neuronProp); }
Example #13
Source File: FeatureMapLayer.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates an empty 2D layer with specified dimensions * * @param dimensions layer dimensions (width and weight) */ public FeatureMapLayer(Dimension2D dimensions, NeuronProperties neuronProperties) { this.dimensions = dimensions; for (int i = 0; i < dimensions.getHeight() * dimensions.getWidth(); i++) { Neuron neuron = NeuronFactory.createNeuron(neuronProperties); addNeuron(neuron); } }
Example #14
Source File: FeatureMapLayer.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates 2D layer with specified dimensions, filled with neurons with * specified properties * * @param dimensions layer dimensions * @param neuronProperties neuron properties */ public FeatureMapLayer(Dimension2D dimensions, NeuronProperties neuronProperties, Dimension2D kernelDimension) { this(dimensions, kernelDimension); for (int i = 0; i < dimensions.getHeight() * dimensions.getWidth(); i++) { Neuron neuron = NeuronFactory.createNeuron(neuronProperties); addNeuron(neuron); } }
Example #15
Source File: ConvolutionalLayer.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates convolutional layer with specified kernel, appropriate map * dimensions in regard to previous layer (fromLayer param) and specified * number of feature maps with default neuron settings for convolutional * layer. * * @param fromLayer previous layer, which will be connected to this layer * @param kernel kernel for all feature maps * @param numberOfMaps number of feature maps to create in this layer * @param transferFunction neuron's transfer function to use */ public ConvolutionalLayer(FeatureMapsLayer fromLayer, Dimension2D kernelDimension, int numberOfMaps, Class <? extends TransferFunction> transferFunction) { Dimension2D fromDimension = fromLayer.getMapDimensions(); int mapWidth = fromDimension.getWidth() - kernelDimension.getWidth() + 1; int mapHeight = fromDimension.getHeight() - kernelDimension.getHeight() + 1; this.mapDimensions = new Dimension2D(mapWidth, mapHeight); NeuronProperties neuronProp = new NeuronProperties(Neuron.class, transferFunction); createFeatureMaps(numberOfMaps, this.mapDimensions, kernelDimension, neuronProp); }
Example #16
Source File: InputLayer.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates a new instance of InputLayer with specified number of input neurons * @param neuronsCount input neurons count for this layer */ public InputLayer(int neuronsCount) { NeuronProperties inputNeuronProperties = new NeuronProperties(InputNeuron.class, Linear.class); for (int i = 0; i < neuronsCount; i++) { Neuron neuron = NeuronFactory.createNeuron(inputNeuronProperties); this.addNeuron(neuron); } }
Example #17
Source File: Layer.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates an instance of Layer with the specified number of neurons with * specified neuron properties * * @param neuronsCount number of neurons in layer * @param neuronProperties properties of neurons in layer */ public Layer(int neuronsCount, NeuronProperties neuronProperties) { this(neuronsCount); for (int i = 0; i < neuronsCount; i++) { Neuron neuron = NeuronFactory.createNeuron(neuronProperties); this.addNeuron(neuron); } }
Example #18
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 #19
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 #20
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 #21
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 #22
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 #23
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 #24
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 #25
Source File: BAM.java From NeurophFramework with Apache License 2.0 | 5 votes |
/** * Creates BAM network architecture * * @param inputNeuronsCount * number of neurons in input layer * @param outputNeuronsCount * number of neurons in output layer * @param neuronProperties * neuron properties */ private void createNetwork(int inputNeuronsCount, int outputNeuronsCount, NeuronProperties neuronProperties) { // set network type this.setNetworkType(NeuralNetworkType.BAM); // create input layer Layer inputLayer = LayerFactory.createLayer(inputNeuronsCount, neuronProperties); // add input layer to network this.addLayer(inputLayer); // create output layer Layer outputLayer = LayerFactory.createLayer(outputNeuronsCount, neuronProperties); // add output layer to network this.addLayer(outputLayer); // create full connectivity from in to out layer ConnectionFactory.fullConnect(inputLayer, outputLayer); // create full connectivity from out to in layer ConnectionFactory.fullConnect(outputLayer, inputLayer); // set input and output cells for this network NeuralNetworkFactory.setDefaultIO(this); // set Hebbian learning rule for this network this.setLearningRule(new BinaryHebbianLearning()); }
Example #26
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 #27
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 #28
Source File: RectifierNeuralNetwork.java From NeurophFramework with Apache License 2.0 | 5 votes |
public RectifierNeuralNetwork(List<Integer> neuronsInLayers) { //this.setNetworkType(NeuralNetworkType.RECTIFIER); NeuronProperties inputNeuronProperties = new NeuronProperties(InputNeuron.class, Linear.class); Layer layer = LayerFactory.createLayer(neuronsInLayers.get(0), inputNeuronProperties); this.addLayer(layer); // create layers Layer prevLayer = layer; for (int layerIdx = 1; layerIdx < neuronsInLayers.size()-1; layerIdx++) { Integer neuronsNum = neuronsInLayers.get(layerIdx); layer = LayerFactory.createLayer(neuronsNum, RectifiedLinear.class); this.addLayer(layer); ConnectionFactory.fullConnect(prevLayer, layer); prevLayer = layer; } int numberOfOutputNeurons = neuronsInLayers.get(neuronsInLayers.size() - 1); Layer outputLayer = LayerFactory.createLayer(numberOfOutputNeurons, Sigmoid.class); this.addLayer(outputLayer); ConnectionFactory.fullConnect(prevLayer, outputLayer); NeuralNetworkFactory.setDefaultIO(this); // set input and output cells for network this.setLearningRule(new MomentumBackpropagation()); this.randomizeWeights(new HeZhangRenSunUniformWeightsRandomizer()); }
Example #29
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 #30
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); }