Package ca.nengo.model.nef.impl

Examples of ca.nengo.model.nef.impl.DecodedOrigin


     
      if ( !(o instanceof DecodedOrigin) ) {
        throw new RuntimeException("Can't plot origin error: Origin must be a DecodedOrigin");
      }
     
      DecodedOrigin origin = (DecodedOrigin) o;
     
      if (ensemble.getDimension()>1){
        doPlotMSE(ensemble,origin,name);
        return;
      }
     
     
//      float[][] encoders = ensemble.getEncoders();

      float[] x = new float[101];
      float[][] idealOutput = new float[x.length][];
      float[][] actualOutput = new float[x.length][];

      NEFNode[] nodes = (NEFNode[]) ensemble.getNodes();
     
      SimulationMode mode = ensemble.getMode();
      float radius = ensemble.getRadii()[0];
      for (int i = 0; i < x.length; i++) {
        x[i] = -radius + (float) i * (2f*radius / (float) (x.length-1));
               
        ensemble.setMode(SimulationMode.CONSTANT_RATE);
        for (int j = 0; j < nodes.length; j++) {
//          ((NEFNode) nodes[j]).setRadialInput(x[i]*encoders[j][0]);
          ((NEFNode) nodes[j]).setRadialInput(getRadialInput(ensemble, j, x[i]));
         
          nodes[j].run(0f, 0f);   
        }
        origin.run(null, 0f, 1f);
        actualOutput[i] = ((RealOutput) origin.getValues()).getValues();
       
        ensemble.setMode(SimulationMode.DIRECT);
        float[] state = new float[ensemble.getDimension()];
        state[0] = x[i];
        origin.run(state, 0f, 1f);
        idealOutput[i] = ((RealOutput) origin.getValues()).getValues();
      }
      ensemble.setMode(mode);
     
      //one plot per output dimension ...
      for (int i = 0; i < idealOutput[0].length; i++) {
View Full Code Here


    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);
View Full Code Here

  public void addBias(int numInterneurons, float tauInterneurons, float tauBias, boolean excitatory, boolean optimize) throws StructuralException {
    if ( !(myOrigin instanceof DecodedOrigin) || !(myTermination instanceof DecodedTermination)) {
      throw new RuntimeException("This feature is only implemented for projections from DecodedOrigins to DecodedTerminations");
    }

    DecodedOrigin baseOrigin = (DecodedOrigin) myOrigin;
    DecodedTermination baseTermination = (DecodedTermination) myTermination;
    NEFEnsemble pre = (NEFEnsemble) baseOrigin.getNode();
    NEFEnsemble post = (NEFEnsemble) baseTermination.getNode();

    myBiasOrigin = pre.addBiasOrigin(baseOrigin, numInterneurons, getUniqueNodeName(post.getName() + "_" + baseTermination.getName()), excitatory);
    myInterneurons = myBiasOrigin.getInterneurons();
    myNetwork.addNode(myInterneurons);
    BiasTermination[] bt = post.addBiasTerminations(baseTermination, tauBias, myBiasOrigin.getDecoders(), baseOrigin.getDecoders());
    myDirectBT = bt[0];
    myIndirectBT = bt[1];
    if (!excitatory) {
            myIndirectBT.setStaticBias(new float[]{-1});
        }
    float[][] tf = new float[][]{new float[]{0, 1/tauInterneurons/tauInterneurons}, new float[]{2/tauInterneurons, 1/tauInterneurons/tauInterneurons}};
    myInterneuronTermination = (DecodedTermination) myInterneurons.addDecodedTermination("bias", MU.I(1), tf[0], tf[1], 0, false);

    myNetwork.addProjection(myBiasOrigin, myDirectBT);
    myNetwork.addProjection(myBiasOrigin, myInterneuronTermination);
    myNetwork.addProjection(myInterneurons.getOrigin(NEFEnsemble.X), myIndirectBT);

    if (optimize) {
      float[][] baseWeights = MU.prod(post.getEncoders(), MU.prod(baseTermination.getTransform(), MU.transpose(baseOrigin.getDecoders())));
      myBiasOrigin.optimizeDecoders(baseWeights, myDirectBT.getBiasEncoders(), excitatory);
      myBiasOrigin.optimizeInterneuronDomain(myInterneuronTermination, myIndirectBT);
    }

    myBiasIsEnabled = true;
View Full Code Here

  /**
   * @see ca.nengo.model.Projection#removeBias()
   */
  public void removeBias() {
    try {
      DecodedOrigin baseOrigin = (DecodedOrigin) myOrigin;
      DecodedTermination baseTermination = (DecodedTermination) myTermination;
      NEFEnsemble pre = (NEFEnsemble) baseOrigin.getNode();
      NEFEnsemble post = (NEFEnsemble) baseTermination.getNode();

      myNetwork.removeProjection(myDirectBT);
      myNetwork.removeProjection(myIndirectBT);
      myNetwork.removeProjection(myInterneuronTermination);
View Full Code Here

      {
        originNodeFullName.append(tempOrigin.getNode().getName());
      }
      else
      {
        DecodedOrigin dOrigin;
        if(tempOrigin instanceof DecodedOrigin)
        {
          dOrigin = (DecodedOrigin) tempOrigin;
          originNodeFullName.append(tempOrigin.getNode().getName());
        }
View Full Code Here

TOP

Related Classes of ca.nengo.model.nef.impl.DecodedOrigin

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.