Examples of NEFEnsemble


Examples of ca.nengo.model.nef.NEFEnsemble

   
    FunctionInput input = new FunctionInput("input", new Function[]{f}, Units.UNK);
    network.addNode(input);
   
    NEFEnsembleFactory ef = new NEFEnsembleFactoryImpl();
    NEFEnsemble pre = ef.make("pre", 400, 1, "nefe_pre", false);
    pre.addDecodedTermination("input", MU.I(1), tauPSC, false);
//    DecodedOrigin baseOrigin = (DecodedOrigin) pre.getOrigin(NEFEnsemble.X);
    network.addNode(pre);
   
    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");   
View Full Code Here

Examples of ca.nengo.model.nef.NEFEnsemble

//    return biasEncoders;
//  }
 
  public void testClone() throws StructuralException, CloneNotSupportedException {
    NEFEnsembleFactory ef = new NEFEnsembleFactoryImpl();
    NEFEnsemble ensemble = ef.make("test", 100, 1);
    long startTime = System.currentTimeMillis();
    ensemble.clone();
    System.out.println(System.currentTimeMillis() - startTime);
  }
View Full Code Here

Examples of ca.nengo.model.nef.NEFEnsemble

      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

Examples of ca.nengo.model.nef.NEFEnsemble

   * Test method for {@link ca.nengo.model.nef.impl.NEFUtil#getOutput(ca.nengo.model.nef.impl.DecodedOrigin, float[][], ca.nengo.model.SimulationMode)}.
   * @throws StructuralException
   */
  public void testGetOutput() throws StructuralException {
    NEFEnsembleFactory ef = new NEFEnsembleFactoryImpl();
    NEFEnsemble ensemble = ef.make("test", 70, new float[]{1, 1, 1});
    DecodedOrigin origin = (DecodedOrigin) ensemble.addDecodedOrigin("test",
        new Function[]{new PostfixFunction("x1", 3), new PostfixFunction("x2", 3)}, Neuron.AXON);
   
    float[][] input = MU.uniform(500, 3, 1);
    float[][] directOutput = NEFUtil.getOutput(origin, input, SimulationMode.DIRECT);
    float[][] constantOutput = NEFUtil.getOutput(origin, input, SimulationMode.CONSTANT_RATE);
View Full Code Here

Examples of ca.nengo.model.nef.NEFEnsemble

   */
  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);
      myNetwork.removeNode(myInterneurons.getName());

      pre.removeDecodedOrigin(myBiasOrigin.getName());
      post.removeDecodedTermination(myDirectBT.getName());
      post.removeDecodedTermination(myIndirectBT.getName());

      myBiasIsEnabled = false;
    } catch (StructuralException e) {
      throw new RuntimeException("Error while trying to remove bias (this is probably a bug in ProjectionImpl)", e);
    }
View Full Code Here

Examples of ca.nengo.model.nef.NEFEnsemble

   */
  protected void setUp() throws Exception {
    super.setUp();
   
    NEFEnsembleFactoryImpl ef = new NEFEnsembleFactoryImpl();
    NEFEnsemble ensemble = ef.make("test", 100, 1);
    myOrigin = (DecodedOrigin) ensemble.getOrigin(NEFEnsemble.X);
//    Plotter.plot(ensemble, NEFEnsemble.X);
  }
View Full Code Here

Examples of ca.nengo.model.nef.NEFEnsemble

     * represents them in a multidimensional origin, and transfers the values to each dendritic ensemble in the network
     * @throws StructuralException
     */
    private void createTransferEnsemble() throws StructuralException
    {
        NEFEnsemble e;
        NEFEnsembleFactoryImpl f = new NEFEnsembleFactoryImpl();
        NodeFactory g = new LIFNeuronFactory();
        int i = 0;
        int currentDim = 0;
        float[][][] w = new float[this.dim][this.dim][1];
        f.setNodeFactory(g);

        e = f.make("Transfer", 1, this.dim);

        //when terminations at the network level are multidimensional, a single multidimensional termination is needed at the level of ...
        //... the tranfer ensemble. Otherwise, single dimensional terminations are needed, each storing their value in a different...
        //...dimension of the transfer ensemble
        if(this.oneDimTerminations == true)
        {
            //creates a weight matrix that takes values from each input and stores them in a different dimension of the ensemble
            while (currentDim<this.dim)
            {

                while (i<this.dim)
                {
                    if (i == currentDim)
                    {
                        w[currentDim][i][0] = 1;
                    }
                    else
                    {
                        w[currentDim][i][0] = 0;
                    }

                    i = i + 1;
                }

                e.addDecodedTermination("i" + currentDim, w[currentDim], 0.007f, false);
                currentDim = currentDim + 1;
                i = 0;
            }
        }
        else //if only one termination is used for multiple dimensions, all that is needed is an identity matrix for the transform
        {
            e.addDecodedTermination("input", MU.I(this.dim), 0.007f, false);
        }
        e.setMode(SimulationMode.DIRECT);
        this.transfer = e;
    }
View Full Code Here

Examples of ca.nengo.model.nef.NEFEnsemble

    /**creates an ensemble of cell bodies
     *there are as many nodes in this ensemble as there are "nonlinear neurons" in the network
     */
    private void createSoma() throws StructuralException
    {
        NEFEnsemble e;
        NEFEnsembleFactoryImpl f = new NEFEnsembleFactoryImpl();
        NodeFactory g;

        //Originally a sigmoid function was given for the soma in the Poirazi et al. article as well.
        //This was not used due to the fact that it characterizes a rate response as opposed to spiking behaviour
View Full Code Here

Examples of ca.nengo.model.nef.NEFEnsemble

        new ConstantFunction(1, .3f) };
    FunctionInput in = new FunctionInput("input", functions, Units.UNK);

    NEFEnsembleFactory ef = new NEFEnsembleFactoryImpl();

    NEFEnsemble A = ef.make("A", 100, 1, "A", false);
    NEFEnsemble B = ef.make("B", 100, 1, "B", false);
    NEFEnsemble C = ef.make("C", 100, 1, "C", false);
    NEFEnsemble D = ef.make("D", 100, 1, "D", false);

    NEFEnsemble rule1a = ef.make("rule1a", 500, 2, "rule1a", false);
    NEFEnsemble rule1b = ef.make("rule1b", 500, 2, "rule1b", false);
    NEFEnsemble rule2 = ef.make("rule2", 200, 1, "rule2", false);
    rule2.collectSpikes(true);

    rule1a.addDecodedOrigin("OR", new Function[] { new MAX(2) },
        Neuron.AXON);
    rule1b.addDecodedOrigin("AND", new Function[] { new MIN(2) },
        Neuron.AXON);
    rule1a.doneOrigins();
    rule1b.doneOrigins();
    rule2.doneOrigins();

    NEFEnsemble output = ef.make("output", 500, 5, "fuzzyoutput", false);

    net.addNode(in);
    net.addNode(A);
    net.addNode(B);
    net.addNode(C);
    net.addNode(D);
    net.addNode(rule1a);
    net.addNode(rule1b);
    net.addNode(rule2);
    net.addNode(output);

    A.addDecodedTermination("in", new float[][] { new float[] { 1f, 0f, 0f,
        0f } }, .005f, false);
    B.addDecodedTermination("in", new float[][] { new float[] { 0f, 1f, 0f,
        0f } }, .005f, false);
    C.addDecodedTermination("in", new float[][] { new float[] { 0f, 0f, 1f,
        0f } }, .005f, false);
    D.addDecodedTermination("in", new float[][] { new float[] { 0f, 0f, 0f,
        1f } }, .005f, false);

    net.addProjection(in.getOrigin(FunctionInput.ORIGIN_NAME), A
        .getTermination("in"));
    net.addProjection(in.getOrigin(FunctionInput.ORIGIN_NAME), B
        .getTermination("in"));
    net.addProjection(in.getOrigin(FunctionInput.ORIGIN_NAME), C
        .getTermination("in"));
    net.addProjection(in.getOrigin(FunctionInput.ORIGIN_NAME), D
        .getTermination("in"));

    rule1a.addDecodedTermination("B", new float[][] { new float[] { 1f },
        new float[] { 0f } }, .005f, false);
    rule1a.addDecodedTermination("C", new float[][] { new float[] { 0f },
        new float[] { 1f } }, .005f, false);
    rule1b.addDecodedTermination("A", new float[][] { new float[] { 1f },
        new float[] { 0f } }, .005f, false);
    rule1b.addDecodedTermination("B or C", new float[][] {
        new float[] { 0f }, new float[] { 1f } }, .005f, false);
    rule2.addDecodedTermination("D", new float[][] { new float[] { 1f } },
        .005f, false);

    net.addProjection(B.getOrigin(NEFEnsemble.X), rule1a
        .getTermination("B"));
    net.addProjection(C.getOrigin(NEFEnsemble.X), rule1a
        .getTermination("C"));
    net.addProjection(A.getOrigin(NEFEnsemble.X), rule1b
        .getTermination("A"));
    net.addProjection(rule1a.getOrigin("OR"), rule1b
        .getTermination("B or C"));
    net
        .addProjection(D.getOrigin(NEFEnsemble.X), rule2
            .getTermination("D"));

    output.addDecodedTermination("rule1", new float[][] {
        new float[] { .4f }, new float[] { .3f }, new float[] { .2f },
        new float[] { .1f }, new float[] { 0f } }, .005f, false);
    output.addDecodedTermination("rule2", new float[][] {
        new float[] { 0f }, new float[] { .1f }, new float[] { .2f },
        new float[] { .3f }, new float[] { .4f } }, .005f, false);

    net.addProjection(rule1b.getOrigin("AND"), output
        .getTermination("rule1"));
    net.addProjection(rule2.getOrigin(NEFEnsemble.X), output
        .getTermination("rule2"));

    float neg = -.3f;
    float pos = .9f;
    float[][] m = new float[][] { new float[] { pos, neg, neg, neg, neg },
        new float[] { neg, pos, neg, neg, neg },
        new float[] { neg, neg, pos, neg, neg },
        new float[] { neg, neg, neg, pos, neg },
        new float[] { neg, neg, neg, neg, pos }, };
    output.addDecodedTermination("recurrent", m, .005f, false);

    Function[] clipped = new Function[] { new Clip(5, 0, 0f, 1f),
        new Clip(5, 1, 0f, 1f), new Clip(5, 2, 0f, 1f),
        new Clip(5, 3, 0f, 1f), new Clip(5, 4, 0f, 1f) };
    output.addDecodedOrigin("recurrent", clipped, Neuron.AXON);

    net.addProjection(output.getOrigin("recurrent"), output
        .getTermination("recurrent"));

    /*
     * Add probes
     */
 
View Full Code Here

Examples of ca.nengo.model.nef.NEFEnsemble

        nodes[i].setMode(SimulationMode.DEFAULT);
      }

      float[][] encoders = myEncoderFactory.genVectors(n, dim);
      float[][] evalPoints = getEvalPointFactory().genVectors(getNumEvalPoints(dim), dim);
      NEFEnsemble result = construct(name, nodes, encoders, myApproximatorFactory, evalPoints, radii);

      addDefaultOrigins(result);

      result.setEnsembleFactory(this);

      return result;
    }
    catch(RuntimeException re)
    {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.