Examples of ActivationFunction


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

    final int toLayerIndex = this.layerIndex[currentLevel];
    final int fromLayerSize = this.layerCounts[currentLevel + 1];
    final int toLayerSize = this.layerFeedCounts[currentLevel];

    final int index = this.weightIndex[currentLevel];
    final ActivationFunction activation = this.flat
        .getActivationFunctions()[currentLevel + 1];

    // handle weights
    int yi = fromLayerIndex;
    for (int y = 0; y < fromLayerSize; y++) {
      final double output = this.layerOutput[yi];
      double sum = 0;
      int xi = toLayerIndex;
      int wi = index + y;
      for (int x = 0; x < toLayerSize; x++) {
        derivative[wi] += output * this.layerDelta[xi];
        sum += this.weights[wi] * this.layerDelta[xi];
        wi += fromLayerSize;
        xi++;
      }

      this.layerDelta[yi] = sum
          * (activation.derivativeFunction(this.layerSums[yi],this.layerOutput[yi]));
      yi++;
    }
  }
 
View Full Code Here

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

    for (int i = 0; i < activationFunctions.length; i++) {
      if (i > 0) {
        result.append(',');
      }

      final ActivationFunction af = activationFunctions[i];
      if (af instanceof ActivationSigmoid) {
        result.append("ENCOG.ActivationSigmoid.create()");
      } else if (af instanceof ActivationTANH) {
        result.append("ENCOG.ActivationTANH.create()");
      } else if (af instanceof ActivationLinear) {
        result.append("ENCOG.ActivationLinear.create()");
      } else if (af instanceof ActivationElliott) {
        result.append("ENCOG.ActivationElliott.create()");
      } else if (af instanceof ActivationElliott) {
        result.append("ENCOG.ActivationElliott.create()");
      } else {
        throw new AnalystCodeGenerationError(
            "Unsupported activatoin function for code generation: "
                + af.getClass().getSimpleName());
      }

    }
    result.append(']');
    return result.toString();
View Full Code Here

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

   * @return The array of flat activations.
   */
  public int[] createActivations(final FlatNetwork flat) {
    final int[] result = new int[flat.getActivationFunctions().length];
    for (int i = 0; i < flat.getActivationFunctions().length; i++) {
      final ActivationFunction af = flat.getActivationFunctions()[i];

      if (af instanceof ActivationLinear) {
        result[i] = 0;
      } else if (af instanceof ActivationTANH) {
        result[i] = 1;
View Full Code Here

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

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

        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

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

   
    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

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

   * @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

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

   *            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

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

    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

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

    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
TOP
Copyright © 2018 www.massapi.com. 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.