Package ca.nengo.model

Examples of ca.nengo.model.Projection


                    UIOrigin originUI = terminationUI.getConnector().getOriginUI();

                    Termination termination = terminationUI.getModel();
                    Origin origin = originUI.getModel();

                    Projection projection = projectionMap.get(termination);
                    if (projection != null && projection.getOrigin() == origin) {
                        /*
                         * Projection already exists
                         */
                        projectionsToAdd.remove(projectionMap.get(termination));

                    } else {
                        projectionsToRemove.add(terminationUI.getConnector());
                    }
                }
            }
        }

        /*
         * Destroy unreferenced projections
         */
        for (UIProjection projectionUI : projectionsToRemove) {
            UITermination terminationUI = projectionUI.getTermination();

            projectionUI.destroy();
            if (!isFirstUpdate) {
                terminationUI.showPopupMessage("REMOVED Projection to "
                        + terminationUI.getNodeParent().getName() + "." + terminationUI.getName());
            }
        }

        /*
         * Construct projections
         */
        for (Projection projection : projectionsToAdd) {
            Origin origin = projection.getOrigin();
            Termination term = projection.getTermination();

            UINeoNode nodeOrigin = getUINode(origin.getNode());

            UINeoNode nodeTerm = getUINode(term.getNode());

View Full Code Here


    network.addNode(pre);
    network.addProjection(input.getOrigin(FunctionInput.ORIGIN_NAME), pre.getTermination("input"));
    NEFEnsemble post = ef.make("post", n, 2);
    network.addNode(post);
    post.addDecodedTermination("input", MU.I(2), .01f, false);
    Projection p = network.addProjection(pre.getOrigin(NEFEnsemble.X), post.getTermination("input"));

    DecodedOrigin o = (DecodedOrigin) pre.getOrigin(NEFEnsemble.X);
    DecodedTermination t = (DecodedTermination) post.getTermination("input");
    float[][] directWeights = MU.prod(post.getEncoders(), MU.prod(t.getTransform(), MU.transpose(o.getDecoders())));
    System.out.println("Direct weights: " + MU.min(directWeights) + " to " + MU.max(directWeights));

    Probe probe = network.getSimulator().addProbe(post.getName(), NEFEnsemble.X, true);
    network.setMode(SimulationMode.CONSTANT_RATE);
    network.run(-1.5f, 1);
    network.setMode(SimulationMode.DEFAULT);
    float[] reference = MU.transpose(DataUtils.filter(probe.getData(), .01f).getValues())[0];

    network.run(-1.5f, 1);
//    Plotter.plot(probe.getData(), "mixed weights");
    float[] mixed = MU.transpose(DataUtils.filter(probe.getData(), .01f).getValues())[0];
    getError(reference, mixed);

    p.addBias(300, .005f, .01f, true, false);
    BiasOrigin bo = (BiasOrigin) pre.getOrigin("post_input");
    BiasTermination bt = (BiasTermination) post.getTermination("input (bias)");
    assertTrue(MU.min(getNetWeights(directWeights, bo, bt)) > -1e-10);
    network.run(-1.5f, 1);
//    Plotter.plot(probe.getData(), "positive non-optimal");
//    float[] positiveNonOptimal = MU.transpose(DataUtils.filter(probe.getData(), .01f).getValues())[0];
//    float error = getError(reference, positiveNonOptimal);
//    assertTrue(error > 1e-10 && error < 5e-4);
    p.removeBias();

    p.addBias(300, .005f, .01f, true, true);
    bo = (BiasOrigin) pre.getOrigin("post_input");
    bt = (BiasTermination) post.getTermination("input (bias)");
    assertTrue(MU.min(getNetWeights(directWeights, bo, bt)) > -1e-10);
    network.run(-1.5f, 1);
//    Plotter.plot(probe.getData(), "positive optimal");
//    float[] positiveOptimal = MU.transpose(DataUtils.filter(probe.getData(), .01f).getValues())[0];
//    float error2 = getError(reference, positiveOptimal);
//    assertTrue(error2 > 1e-10 && error2 < 2.5e-4 && error2 < error);
    p.removeBias();
  }
View Full Code Here

    NEFEnsemble post = ef.make("post", 200, 1, "nefe_post", false);
//    DecodedTermination baseTermination = (DecodedTermination) post.addDecodedTermination("pre", MU.I(1), tauPSC, false);
    network.addNode(post);
   
    network.addProjection(input.getOrigin(FunctionInput.ORIGIN_NAME), pre.getTermination("input"));
    Projection projection = network.addProjection(pre.getOrigin(NEFEnsemble.X), post.getTermination("pre"));
   
    Probe pPost = network.getSimulator().addProbe("post", NEFEnsemble.X, true);
    network.run(0, 2);
    TimeSeries ideal = pPost.getData();
    Plotter.plot(pPost.getData(), .005f, "mixed weights result");   
   
    //remove negative weights ...
    System.out.println("Minimum weight without bias: " + MU.min(projection.getWeights()));
    projection.addBias(100, .005f, tauPSC, true, false);
    System.out.println("Minimum weight with bias: " + MU.min(projection.getWeights()));
    pPost.reset();
    network.run(0, 2);
    TimeSeries diff = new TimeSeriesImpl(ideal.getTimes(), MU.difference(ideal.getValues(), pPost.getData().getValues()), ideal.getUnits());
    Plotter.plot(diff, .01f, "positive weights");
   
    projection.removeBias();
    projection.addBias(100, tauPSC/5f, tauPSC, true, true);
    pPost.reset();
    Probe pInter = network.getSimulator().addProbe("post:pre:interneurons", NEFEnsemble.X, true);
    network.run(0, 2);
    diff = new TimeSeriesImpl(ideal.getTimes(), MU.difference(ideal.getValues(), pPost.getData().getValues()), ideal.getUnits());
    Plotter.plot(diff, .01f, "positive weights optimized");
View Full Code Here

      throw new StructuralException("There is already an Origin connected to the specified Termination");
    } else if (origin.getDimensions() != termination.getDimensions()) {
      throw new StructuralException("Can't connect Origin of dimension " + origin.getDimensions()
          + " to Termination of dimension " + termination.getDimensions());
    } else {
      Projection result = new ProjectionImpl(origin, termination, this);
      myProjectionMap.put(termination, result);
      getSimulator().initialize(this);
      fireVisibleChangeEvent();
 
      return result;
View Full Code Here

  /**
   * @see ca.nengo.model.Network#removeProjection(ca.nengo.model.Termination)
   */
  public void removeProjection(Termination termination) throws StructuralException {
    if (myProjectionMap.containsKey(termination)) {
      Projection p = myProjectionMap.get(termination);
      p.getTermination().reset(false);
     
      myProjectionMap.remove(termination);
    } else {
      throw new StructuralException("The Network contains no Projection ending on the specified Termination");
    }
View Full Code Here

      try {
        Origin newOrigin = result.getNode(oldProjection.getOrigin().getNode().getName())
          .getOrigin(oldProjection.getOrigin().getName());
        Termination newTermination = result.getNode(oldProjection.getTermination().getNode().getName())
          .getTermination(oldProjection.getTermination().getName());
        Projection newProjection = new ProjectionImpl(newOrigin, newTermination, result);
        result.myProjectionMap.put(newTermination, newProjection);
      } catch (StructuralException e) {
        throw new CloneNotSupportedException("Problem copying Projectio: " + e.getMessage());
      }
    }
View Full Code Here

TOP

Related Classes of ca.nengo.model.Projection

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.