Package org.encog

Examples of org.encog.EncogError


      reader.close();

      return sb.toString();
    } catch (final IOException e) {
      throw new EncogError(e);
    }
  }
View Full Code Here


          return result;
        }
      }
    }

    throw new EncogError("Unknown method type: " + methodType);
  }
View Full Code Here

   */
  public final MLMethod create(final String architecture, final int input,
      final int output) {
   
    if( input<=0 ) {
      throw new EncogError("Must have at least one input for feedforward.");
    }
   
    if( output<=0 ) {
      throw new EncogError("Must have at least one output for feedforward.");
    }
   
   
    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()) {
          questionPhase++;
          if (questionPhase > 2) {
            throw new EncogError("Only two ?'s may be used.");
          }
        }

        if (layer.getCount() == 0) {
          throw new EncogError("Unknown architecture element: "
              + architecture + ", can't parse: " + part);
        }

        result.addLayer(new BasicLayer(af, bias,
            layer.getCount()));
View Full Code Here

        if (result != null) {
          return result;
        }
      }
    }
    throw new EncogError("Unknown training type: " + type);
  }
View Full Code Here

  public final MLTrain create(final MLMethod method,
      final MLDataSet training,
      final String argsStr) {

    if (!(method instanceof SVM)) {
      throw new EncogError(
          "SVM Train training cannot be used on a method of type: "
              + method.getClass().getName());
    }
   
    final Map<String, String> args = ArchitectureParse.parseParams(argsStr);
View Full Code Here

  public final MLMethod create(final String architecture, final int input,
      final int output) {

    final List<String> layers = ArchitectureParse.parseLayers(architecture);
    if (layers.size() != MAX_LAYERS) {
      throw new EncogError(
          "PNN Networks must have exactly three elements, "
          + "separated by ->.");
    }

    final ArchitectureLayer inputLayer = ArchitectureParse.parseLayer(
View Full Code Here

  public final MLMethod create(final String architecture, final int input,
      final int output) {

    final List<String> layers = ArchitectureParse.parseLayers(architecture);
    if (layers.size() != MAX_LAYERS) {
      throw new EncogError(
          "SRN Networks must have exactly three elements, "
          + "separated by ->.");
    }

    final ArchitectureLayer inputLayer = ArchitectureParse.parseLayer(
View Full Code Here

   
    final ClassLoader loader = ResourceInputStream.class.getClassLoader();
    InputStream result = loader.getResourceAsStream(resource);

    if (result == null) {
      throw new EncogError("Can't open resource: " + resource);
    }   
   
    return result;
  }
View Full Code Here

      InputStream is = openResourceInputStream(resource);
      String result = FileUtil.readStreamAsString(is);
      is.close();
      return result;
    } catch (IOException ex) {
      throw new EncogError(ex);
    }
  }
View Full Code Here

    final MLMethod method = (MLMethod) EncogDirectoryPersistence
        .loadObject(methodFile);

    if (!(method instanceof MLFactory)) {
      throw new EncogError("Code generation not yet supported for: "
          + method.getClass().getName());
    }

    final FlatNetwork flat = ((ContainsFlat) method).getFlat();
View Full Code Here

TOP

Related Classes of org.encog.EncogError

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.