コード例 #1
0
  /**
   * Creates and returns a new instance of Multi Layer Perceptron
   *
   * @param layersStr space separated number of neurons in layers
   * @param transferFunctionType transfer function type for neurons
   * @return instance of Multi Layer Perceptron
   */
  public static MultiLayerPerceptron createMLPerceptron(
      String layersStr,
      TransferFunctionType transferFunctionType,
      Class learningRule,
      boolean useBias,
      boolean connectIO) {
    ArrayList<Integer> layerSizes = VectorParser.parseInteger(layersStr);
    NeuronProperties neuronProperties = new NeuronProperties(transferFunctionType, useBias);
    MultiLayerPerceptron nnet = new MultiLayerPerceptron(layerSizes, neuronProperties);

    // set learning rule - TODO: use reflection here
    if (learningRule.getName().equals(BackPropagation.class.getName())) {
      nnet.setLearningRule(new BackPropagation());
    } else if (learningRule.getName().equals(MomentumBackpropagation.class.getName())) {
      nnet.setLearningRule(new MomentumBackpropagation());
    } else if (learningRule.getName().equals(DynamicBackPropagation.class.getName())) {
      nnet.setLearningRule(new DynamicBackPropagation());
    } else if (learningRule.getName().equals(ResilientPropagation.class.getName())) {
      nnet.setLearningRule(new ResilientPropagation());
    }

    // connect io
    if (connectIO) {
      nnet.connectInputsToOutputs();
    }

    return nnet;
  }
コード例 #2
0
 /**
  * Creates and returns a new instance of Multi Layer Perceptron
  *
  * @param layersStr space separated number of neurons in layers
  * @param transferFunctionType transfer function type for neurons
  * @return instance of Multi Layer Perceptron
  */
 public static MultiLayerPerceptron createMLPerceptron(
     String layersStr, TransferFunctionType transferFunctionType) {
   ArrayList<Integer> layerSizes = VectorParser.parseInteger(layersStr);
   MultiLayerPerceptron nnet = new MultiLayerPerceptron(layerSizes, transferFunctionType);
   return nnet;
 }