예제 #1
0
  /** Sets default input and output neurons for network (first layer as input, last as output) */
  public static void setDefaultIO(NeuralNetwork nnet) {
    ArrayList<Neuron> inputNeuronsList = new ArrayList<Neuron>();
    Layer firstLayer = nnet.getLayerAt(0);
    for (Neuron neuron : firstLayer.getNeurons()) {
      if (!(neuron instanceof BiasNeuron)) { // dont set input to bias
        // neurons
        inputNeuronsList.add(neuron);
      }
    }

    Neuron[] inputNeurons = new Neuron[inputNeuronsList.size()];
    inputNeurons = inputNeuronsList.toArray(inputNeurons);
    Neuron[] outputNeurons = ((Layer) nnet.getLayerAt(nnet.getLayersCount() - 1)).getNeurons();

    nnet.setInputNeurons(inputNeurons);
    nnet.setOutputNeurons(outputNeurons);
  }
 private void fillAttributes() {
   int layerIdx = nnet.getLayersCount() - 1; // output layerIdx by default
   Attribute attr1;
   Attribute attr2 = null;
   if (layerCombo.isEnabled()) {
     layerIdx = (Integer) layerCombo.getSelectedItem() - 1;
   }
   attr1 = new Attribute(layerIdx, false, "Layer");
   if (attributeTxtField.isEnabled()) {
     attribute = Integer.parseInt(attributeTxtField.getText());
     attr2 = new Attribute(attribute, false, "Input");
   }
   graphBuilder.setAttribute1(attr1);
   graphBuilder.setAttribute2(attr2);
   outputNeuronCount = nnet.getLayerAt(layerIdx).getNeuronsCount();
 }
 @Override
 public void setNeuralNetwork(NeuralNetwork neuralNetwork) {
   super.setNeuralNetwork(neuralNetwork);
   int neuronsNum = neuralNetwork.getLayerAt(1).getNeuronsCount();
   mapSize = (int) Math.sqrt(neuronsNum);
 }