Package org.encog.engine.network.activation

Examples of org.encog.engine.network.activation.ActivationFunction


    } else {
      name = fn.toLowerCase();
      params = new double[0];
    }

    ActivationFunction af = allocateAF(name);
   
    if( af==null ) {
      return null;
    }

    if (af.getParamNames().length != params.length) {
      throw new EncogError(name + " expected "
          + af.getParamNames().length + ", but " + params.length
          + " were provided.");
    }

    for (int i = 0; i < af.getParamNames().length; i++) {
      af.setParam(i, params[i]);
    }

    return af;
  }
View Full Code Here


        MLMethodFactory.PROPERTY_POPULATION_SIZE, false, 1000);
   
    final int cycles = holder.getInt(
        MLMethodFactory.PROPERTY_CYCLES, false, NEATPopulation.DEFAULT_CYCLES);
   
    ActivationFunction af = this.factory.create(
        holder.getString(MLMethodFactory.PROPERTY_AF, false, MLActivationFactory.AF_SSIGMOID));

    NEATPopulation pop = new NEATPopulation(input,output,populationSize);
    pop.reset();
    pop.setActivationCycles(cycles);
View Full Code Here

   
    if( network.getLayerCount()<1 ) {
      throw new EncogError("Neural network does not have an output layer.");
    }
   
    ActivationFunction outputFunction = network.getActivation(network.getLayerCount()-1);
   
    double[] d = { -1000, -100, -50 };
    outputFunction.activationFunction(d, 0, d.length);
   
    if( d[0]>0 && d[1]>0 && d[2]>0 ) {
      inputLow=0;
    }
   
View Full Code Here

   * @return The newly created context layer.
   */
  public FreeformLayer createContext(final FreeformLayer source,
      final FreeformLayer target) {
    final double biasActivation = 0.0;
    ActivationFunction activatonFunction = null;

    if (source.getNeurons().get(0).getOutputs().size() < 1) {
      throw new FreeformNetworkError(
          "A layer cannot have a context layer connected if there are no other outbound connections from the source layer.  Please connect the source layer somewhere else first.");
    }
View Full Code Here

   *            True if this is a tanh activation, false for sigmoid.
   */
  public FlatNetwork(final int input, final int hidden1, final int hidden2,
      final int output, final boolean tanh) {

    final ActivationFunction linearAct = new ActivationLinear();
    FlatLayer[] layers;
    final ActivationFunction act = tanh ? new ActivationTANH()
        : new ActivationSigmoid();

    if ((hidden1 == 0) && (hidden2 == 0)) {
      layers = new FlatLayer[2];
      layers[0] = new FlatLayer(linearAct, input,
View Full Code Here

    setAdjustedScore(0);
    this.inputCount = inputCount;
    this.outputCount = outputCount;

    // get the activation function
    ActivationFunction af = pop.getActivationFunctions().pickFirst();

    // first bias
    int innovationID = 0;
    NEATNeuronGene biasGene = new NEATNeuronGene(NEATNeuronType.Bias, af,
        inputCount, innovationID++);
View Full Code Here

    final NEATInnovation innovation = ((NEATPopulation)getOwner().getPopulation()).getInnovations()
        .findInnovationSplit(from, to);

    // add the splitting neuron
    final ActivationFunction af = ((NEATPopulation)getOwner().getPopulation())
        .getActivationFunctions().pick(new Random());

    target.getNeuronsChromosome().add(
        new NEATNeuronGene(NEATNeuronType.Hidden, af, innovation
            .getNeuronID(), innovation.getInnovationID()));
View Full Code Here

        flat.setActivationFunctions(new ActivationFunction[flat
            .getLayerCounts().length]);

        for (final String line : section.getLines()) {
          ActivationFunction af = null;
          final List<String> cols = EncogFileSection
              .splitColumns(line);
         
          // if this is a class name with a path, then do not default to inside of the Encog package.
          String name;
          if( cols.get(0).indexOf('.')!=-1 ) {
            name = cols.get(0);
          } else {
            name = "org.encog.engine.network.activation."
                + cols.get(0);
          }
         
          try {
            final Class<?> clazz = Class.forName(name);
            af = (ActivationFunction) clazz.newInstance();
          } catch (final ClassNotFoundException e) {
            throw new PersistError(e);
          } catch (final InstantiationException e) {
            throw new PersistError(e);
          } catch (final IllegalAccessException e) {
            throw new PersistError(e);
          }

          for (int i = 0; i < af.getParamNames().length; i++) {
            af.setParam(i,
                CSVFormat.EG_FORMAT.parse(cols.get(i + 1)));
          }

          flat.getActivationFunctions()[index++] = af;
        }
View Full Code Here

          } else if (cols.get(0).equalsIgnoreCase("n")) {
            final NEATNeuronGene neuronGene = new NEATNeuronGene();
            final int geneID = Integer.parseInt(cols.get(1));
            neuronGene.setId(geneID);

            final ActivationFunction af = EncogFileSection
                .parseActivationFunction(cols.get(2));
            neuronGene.setActivationFunction(af);

            neuronGene.setNeuronType(PersistNEATPopulation
                .stringToNeuronType(cols.get(3)));
View Full Code Here

    if (pop.isHyperNEAT()) {
      out.writeProperty(NEATPopulation.PROPERTY_NEAT_ACTIVATION,
          PersistNEATPopulation.TYPE_CPPN);
    } else {
      final ActivationFunction af = pop.getActivationFunctions()
          .getList().get(0).getObj();
      out.writeProperty(NEATPopulation.PROPERTY_NEAT_ACTIVATION, af);
    }

    out.writeProperty(PersistConst.INPUT_COUNT, pop.getInputCount());
View Full Code Here

TOP

Related Classes of org.encog.engine.network.activation.ActivationFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.