Package org.encog.engine.network.activation

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


   * @param network
   *            The network to compile for.
   */
  public void compile(final FlatNetwork network) {

    final ActivationFunction activation = network.getActivationFunctions()[0];
    final StringBuilder source = new StringBuilder();

    source.append("#define ACTIVATION(x,slope)");
    source.append(activation.getOpenCLExpression(false));
    source.append("\r\n");

    source.append(ResourceLoader.loadString(getSourceName()));
    setCLSource(source.toString());
   
View Full Code Here


   *            The network to compile for.
   */
  public void compile(final Map<String, String> options,
      final OpenCLTrainingProfile profile, final FlatNetwork network) {

    final ActivationFunction activation = network.getActivationFunctions()[0];
    final StringBuilder source = new StringBuilder();

    source.append("#define ACTIVATION(x,slope)");
    source.append(activation.getOpenCLExpression(false));
    source.append("\r\n");

    source.append("#define DERIVATIVE(x,slope)");
    source.append(activation.getOpenCLExpression(true));
    source.append("\r\n");

    source.append(ResourceLoader.loadString(getSourceName()));
    setCLSource(source.toString());

View Full Code Here

      value = params.get(name);
      if (value == null) {
        throw new PersistError("Missing property: " + name);
      }

      ActivationFunction af = null;
      final String[] cols = value.split("\\|");

      final String afName = "org.encog.engine.network.activation." + cols[0];
      try {
        final Class<?> clazz = Class.forName(afName);
        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[i + 1]));
      }

      return af;

    } catch (final Exception ex) {
View Full Code Here

  }

  public void changeEquation() {
    boolean der = this.derivative.isSelected();
    ActivationFunction newActivation = null;
   
    switch (this.select.getSelectedIndex()) {
    case 0:
      newActivation = new ActivationBiPolar();
      break;
    case 1:
      newActivation = new ActivationCompetitive();
      break;
    case 2:
      newActivation = new ActivationGaussian(0, 1, 1);
      break;
    case 3:
      newActivation = new ActivationLinear();
      break;
    case 4:
      newActivation = new ActivationLOG();
      break;
    case 5:
      newActivation = new ActivationSigmoid();
      break;
    case 6:
      newActivation = new ActivationSIN();
      break;
    case 7:
      newActivation = new ActivationSoftMax();
      break;
    case 8:
      newActivation = new ActivationStep();
      break;           
    case 9:
      newActivation = new ActivationTANH();
      break;
    case 10:
      newActivation = new ActivationRamp();
      break;     

    }
   
    if( this.activation.getClass() != newActivation.getClass() )
    {
      this.activation = newActivation;
    }
   
    this.equation.setupEquation(newActivation,!der);
View Full Code Here

  public ActivationFunction create(String fn) {
   
    for (EncogPluginBase plugin : Encog.getInstance().getPlugins()) {
      if (plugin instanceof EncogPluginService1) {
        ActivationFunction result = ((EncogPluginService1) plugin).createActivationFunction(fn);
        if (result != null) {
          return result;
        }
      }
    }
View Full Code Here

    }
   
   
    final BasicNetwork result = new BasicNetwork();
    final List<String> layers = ArchitectureParse.parseLayers(architecture);
    ActivationFunction af = new ActivationLinear();

    int questionPhase = 0;
    for (final String layerStr : layers) {
      int defaultCount;
      // determine default
      if (questionPhase == 0) {
        defaultCount = input;
      } else {
        defaultCount = output;
      }

      final ArchitectureLayer layer = ArchitectureParse.parseLayer(
          layerStr, defaultCount);
      final boolean bias = layer.isBias();

      String part = layer.getName();
      if (part != null) {
        part = part.trim();
      } else {
        part = "";
      }
     
      ActivationFunction lookup = this.factory.create(part);
     
      if (lookup!=null) {
        af = lookup;
      } else {
        if (layer.isUsedDefault()) {
View Full Code Here

  private void restructureFeedforward() {
    CreateFeedforward dialog = new CreateFeedforward(EncogWorkBench
        .getInstance().getMainWindow());
    BasicNetwork network = (BasicNetwork)method;

    ActivationFunction oldActivationOutput = network.getActivation(network
        .getLayerCount() - 1);
    dialog.setActivationFunctionOutput(oldActivationOutput);
    dialog.getInputCount().setValue(network.getInputCount());
    dialog.getOutputCount().setValue(network.getOutputCount());
    int hiddenLayerCount = network.getLayerCount() - 2;

    ActivationFunction oldActivationHidden = new ActivationTANH();
    for (int i = 0; i < hiddenLayerCount; i++) {
      int num = network.getLayerNeuronCount(i + 1);
      String str = "Hidden Layer " + (i + 1) + ": " + num + " neurons";
      dialog.getHidden().getModel().addElement(str);
    }
View Full Code Here

    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

    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

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

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.