/** * Create an instance of {@link Neuron } * */ public Neuron createNeuron() { return new Neuron(); }
Neuron n = new Neuron(); n.setId( "" + counter++ ); n.setBias( weights[ wtsIndex++ ] ); for ( int k = 0; k < inputfieldNames.length; k++ ) { Synapse con = new Synapse(); con.setFrom( "" + k ); con.setWeight( weights[ wtsIndex++ ] ); n.getCons().add( con ); Neuron n = new Neuron(); n.setId( "" + counter++ ); n.setBias( weights[ wtsIndex++ ] ); for ( int k = 0; k < hiddenSize; k++ ) { Synapse con = new Synapse(); con.setFrom( "" + ( k + inputfieldNames.length ) ); con.setWeight( weights[ wtsIndex++ ] ); n.getCons().add( con );
NeuralLayer l2 = (NeuralLayer) n2.getExtensionsAndNeuralLayersAndNeuralInputs().get( 3 ); assertEquals( l1.getNeurons().get( 4 ).getCons().get( 2 ).getWeight(), l2.getNeurons().get( 4 ).getCons().get( 2 ).getWeight(), 1e-9 ); assertEquals( weights[ ( inputfieldNames.length + 1 ) * 4 + 3 ], l2.getNeurons().get( 4 ).getCons().get( 2 ).getWeight(), 1e-9 );
NeuralLayer l2 = (NeuralLayer) n2.getExtensionsAndNeuralLayersAndNeuralInputs().get( 3 ); assertEquals( l1.getNeurons().get( 4 ).getCons().get( 2 ).getWeight(), l2.getNeurons().get( 4 ).getCons().get( 2 ).getWeight(), 1e-9 ); assertEquals( weights[ ( inputfieldNames.length + 1 ) * 4 + 3 ], l2.getNeurons().get( 4 ).getCons().get( 2 ).getWeight(), 1e-9 );