Package trust.jfcm

Examples of trust.jfcm.Concept


       * compute errors on the output nodes
       */
      List<EntryStructure> outputs = e.getOutputs();
      for(int i=0; i<outputs.size(); i++){
        EntryStructure e1 = outputs.get(i);
        Concept c = e1.getConcept();
       
        if(c==null)
          System.err.println("Error: Concept "+e1.getConcept().getName()+" not found");
       
       
          LearningConcept lc = null;
          if(c instanceof LearningConcept)
            lc = (LearningConcept) c;
         
          if(lc != null && lc.isOutput()){
            OutputLearningConcept oc = (OutputLearningConcept) lc;
            System.out.println("  Output concept: "+c.getName());
            System.out.println("  Desirable output: "+oc.getDesirableOutput()+", output: "+oc.getOutput().doubleValue());
            System.out.println("  Error on output concept: "+c.getName()+": "+(oc.getDesirableOutput() - oc.getOutput().doubleValue()));
           
          }
         
      }
    }
View Full Code Here


    Element elemConcepts = doc.createElement("concepts");
    elem.appendChild(elemConcepts);

    Iterator<Concept> cIter = map.getConceptsIterator();
    while (cIter.hasNext()) {
      Concept c = cIter.next();
      Element elemConcept = doc.createElement("concept");
      elemConcept.setAttribute("name", c.getName());
      if (c.getDescription() != null) {
        Element elemDescription = doc.createElement("description");
        elemDescription.setTextContent(c.getDescription());
        elemConcept.appendChild(elemDescription);
      }

      if (c.getConceptActivator() != null) {
        if (c.getConceptActivator() instanceof SignumActivator) {
          SignumActivator act = (SignumActivator) c.getConceptActivator();
          elemConcept.setAttribute("act", "SIGNUM");
          Element paramElem = doc.createElement("param");
          paramElem.setAttribute("name", "threshold");
          paramElem.setAttribute("value", Double.toString(act.getThreshold()));
          elemConcept.appendChild(paramElem);

        } else if (c.getConceptActivator() instanceof SigmoidActivator) {
          SigmoidActivator act = (SigmoidActivator) c.getConceptActivator();
          elemConcept.setAttribute("act", "SIGMOID");
          Element paramElem = doc.createElement("param");
          paramElem.setAttribute("name", "k");
          paramElem.setAttribute("value", Double.toString(act.getK()));
          elemConcept.appendChild(paramElem);

        } else if (c.getConceptActivator() instanceof HyperbolicTangentActivator) {
          HyperbolicTangentActivator act = (HyperbolicTangentActivator) c
              .getConceptActivator();
          elemConcept.setAttribute("act", "TANH");
          Element paramElem = doc.createElement("param");
          paramElem.setAttribute("name", "threshold");
          paramElem.setAttribute("value", Double.toString(act.getThreshold()));
          elemConcept.appendChild(paramElem);
        }
      }
      if (c.getInput() != null) {
        elemConcept.setAttribute("input", c.getInput().toString());
      }
      if (c.getOutput() != null) {
        elemConcept.setAttribute("output", c.getOutput().toString());
      }
      if (c.isFixedOutput()) {
        elemConcept.setAttribute("fixed", "true");
      }

      elemConcepts.appendChild(elemConcept);
    }
View Full Code Here

     * compute errors on the output nodes
     */
    double error = 0;
    for(int i=0; i<outputs.size(); i++){
      EntryStructure e1 = outputs.get(i);
      Concept c = e1.getConcept();
     
      if(c==null)
        System.err.println("Error: Concept "+e1.getConcept().getName()+" not found");
     
     
View Full Code Here

    /*
     * Set desirable outputs
     */
    for(int i=0; i<outputs.size(); i++){
      EntryStructure e1 = outputs.get(i);
      Concept c = e1.getConcept();
     
      if(c==null)
        System.err.println("Error: Concept "+e1.getConcept().getName()+" not found");
     
     
View Full Code Here

    //printErrorFlag();
    int num_completed = 0;
    while(num_completed < map.getNumLearningConcepts()){
      Iterator<Concept> it = map.getConceptsIterator();
      while(it.hasNext()){
        Concept c = it.next();
       
        if(c instanceof LearningConcept){
          LearningConcept lc = (LearningConcept) c;
          if(!lc.isErrorCalculated()){
           
View Full Code Here

     
      WeightedConnection wconn = null;
      if(conn instanceof WeightedConnection)
        wconn = (WeightedConnection) conn;
     
      Concept cout = wconn.getTo();
      LearningConcept lout = null;
      if(cout instanceof LearningConcept)
        lout = (LearningConcept) cout;
     
      if(!lout.isErrorCalculated())
View Full Code Here

   */
  private void updateNetworkWeights(){
    //System.out.println("- Update weights...");
    Iterator<Concept> it = map.getConcepts().values().iterator();
    while(it.hasNext()){
      Concept c = it.next();
       
      if(c instanceof LearningConcept){
        LearningConcept lc = (LearningConcept) c;
        Set<FcmConnection> out = lc.getOutConnections();
        Iterator<FcmConnection> it1 = out.iterator();
View Full Code Here

      String description = xpath.evaluate("description/text()", connElem);
      if (StringUtils.isNotBlank(description)) {
        conn.setDescription(description);
      }
 
      Concept c;
 
      s = xpath.evaluate("@from", connElem);
      if (StringUtils.isBlank(s)) {
        throw new Exception("Missing \"from\" reference in connection \"" + conn.getName()
            + "\"");
View Full Code Here

    }
 
  private static Concept parseConcept(XPath xpath, Element conceptElem)
    throws XPathExpressionException {
   
    Concept c = new Concept();
    c.setName(xpath.evaluate("@name", conceptElem));
   
    String description = xpath.evaluate("description/text()", conceptElem);
    if (StringUtils.isNotBlank(description)) {
      c.setDescription(description);
    }
   
   
    /* threshold parameter */
    Element thresholdParam = (Element) xpath.evaluate("param[@name='threshold']", conceptElem,
        XPathConstants.NODE);
    Double threshold = null;
    if (thresholdParam != null) {
      threshold = Double.parseDouble(xpath.evaluate("@value", thresholdParam));
    }
   
    /* act attribute */
    String actAttr = conceptElem.getAttribute("act");
    if ("SIGNUM".equals(actAttr)) {
      SignumActivator act = new SignumActivator();
      if (threshold != null) {
        act.setThreshold(threshold);
      }
      c.setConceptActivator(act);
   
    } else if ("SIGMOID".equals(actAttr)) {
      SigmoidActivator act = new SigmoidActivator();
      Element kParam = (Element) xpath.evaluate("param[@name='k']", conceptElem,
          XPathConstants.NODE);
      Double k = null;
      if (kParam != null) {
        k = Double.parseDouble(xpath.evaluate("@value", kParam));
      }
      if (k != null) {
        act.setK(k);
      }
      c.setConceptActivator(act);
   
    } else if ("TANH".equals(actAttr)) {
      HyperbolicTangentActivator act = new HyperbolicTangentActivator();
      /* add alpha parameter */
      Element alphaParam = (Element) xpath.evaluate("param[@name='alpha']", conceptElem,
          XPathConstants.NODE);
      Double alpha = null;
      if (alphaParam != null) {
        alpha = Double.parseDouble(xpath.evaluate("@value", alphaParam));
      }
      if (alpha != null) {
        act.setAlpha(alpha);
      }
     
      if (threshold != null) {
        act.setThreshold(threshold);
      }
      c.setConceptActivator(act);
    } else if ("IDENTITY".equals(actAttr)) {
      IdentityActivator act = new IdentityActivator();
      c.setConceptActivator(act);
    }
   
   
   
    String s;
    s = xpath.evaluate("@input", conceptElem);
    if (StringUtils.isNotBlank(s)) {
      c.setInput(Double.parseDouble(s));
    }
    s = xpath.evaluate("@output", conceptElem);
    if (StringUtils.isNotBlank(s)) {
      c.setOutput(Double.parseDouble(s));
    }
    s = xpath.evaluate("@fixed", conceptElem);
    if (StringUtils.isNotBlank(s)) {
      c.setFixedOutput(Boolean.parseBoolean(s));
    }
   
    return c;
  }
View Full Code Here

       * compute errors on the output nodes
       */
      List<EntryStructure> outputs = e.getOutputs();
      for(int i=0; i<outputs.size(); i++){
        EntryStructure e1 = outputs.get(i);
        Concept c = e1.getConcept();
       
        if(c==null)
          System.err.println("Error: Concept "+e1.getConcept().getName()+" not found");
       
       
          LearningConcept lc = null;
          if(c instanceof LearningConcept)
            lc = (LearningConcept) c;
         
          if(lc != null && lc.isOutput()){
            OutputLearningConcept oc = (OutputLearningConcept) lc;
            logger.debug("");
            logger.debug("  Output concept: "+c.getName());
            logger.debug("  Desirable output: "+oc.getDesirableOutput()+", output: "+oc.getOutput().doubleValue());
            logger.debug("  Error on output concept: "+c.getName()+": "+(oc.getDesirableOutput() - oc.getOutput().doubleValue()));
           
          }
         
      }
    }
View Full Code Here

TOP

Related Classes of trust.jfcm.Concept

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.