Package ca.nengo.model.nef.impl

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


    }

    protected Node createNode(ConfigResult prop, String name) {
        try {

            NEFEnsembleFactory ef = new NEFEnsembleFactoryImpl();
            Integer numOfNeurons = (Integer) prop.getValue(pNumOfNodes);
            Integer dimensions = (Integer) prop.getValue(pDim);

            /*
             * Advanced properties, these may not necessarily be configued, so
             */
            ApproximatorFactory approxFactory = (ApproximatorFactory) prop.getValue(pApproximator);
            NodeFactory nodeFactory = (NodeFactory) prop.getValue(pNodeFactory);
            Sign encodingSign = (Sign) prop.getValue(pEncodingSign);
            Float encodingDistribution = (Float) prop.getValue(pEncodingDistribution);
            Float radius = (Float) prop.getValue(pRadius);
            Float noise = (Float) prop.getValue(pNoise);

            if (nodeFactory != null) {
                ef.setNodeFactory(nodeFactory);
            }

            if (approxFactory != null) {
                ef.setApproximatorFactory(approxFactory);
            }
            if (noise != null) {
                ApproximatorFactory f=ef.getApproximatorFactory();
                if (f instanceof WeightedCostApproximator.Factory) {
                    ((WeightedCostApproximator.Factory)f).setNoise(noise);
                }
            }

            if (encodingSign != null) {
                if (encodingDistribution == null) {
                    encodingDistribution = 0f;
                }
                VectorGenerator vectorGen = new RandomHypersphereVG(true, 1, encodingDistribution);
                if (encodingSign == Sign.Positive) {
                    vectorGen = new Rectifier(vectorGen, true);
                } else if (encodingSign == Sign.Negative) {
                    vectorGen = new Rectifier(vectorGen, false);
                }
                ef.setEncoderFactory(vectorGen);
            }

            if (radius==null) {
                NEFEnsemble ensemble = ef.make(name, numOfNeurons, dimensions);
                return ensemble;
            } else {
                float[] radii=new float[dimensions];
                for (int i=0; i<dimensions; i++) {
                    radii[i]=radius.floatValue();
                }
                NEFEnsemble ensemble = ef.make(name, numOfNeurons, radii);
                return ensemble;
            }
        } catch (StructuralException e) {
          Util.debugMsg("StructuralException: " + e.toString());

View Full Code Here


  /*
   * Test method for 'ca.nengo.sim.impl.WriteToDiskSimulatorListener'
   */
  public void testBasicWriting() throws StructuralException, SimulationException {
    Network network = new NetworkImpl();
    NEFEnsembleFactory factory = new NEFEnsembleFactoryImpl();
    NEFEnsemble ensemble = factory.make("Ensemble",100,2);
    File file = new File("testWTDSL.csv");
   
    network.addNode(ensemble);
   
    Probe probe = network.getSimulator().addProbe("Ensemble", "X", true);
View Full Code Here

  /*
   * Test method for 'ca.nengo.sim.impl.WriteToDiskSimulatorListener'
   */
  public void testInterval() throws StructuralException, SimulationException, FileNotFoundException {
    Network network = new NetworkImpl();
    NEFEnsembleFactory factory = new NEFEnsembleFactoryImpl();
    NEFEnsemble ensemble = factory.make("Ensemble",100,2);
    File file = new File("testWTDSL.csv");
   
    network.addNode(ensemble);
   
    float interval = 0.005f;
View Full Code Here

  public void testAddBias2D() throws StructuralException, SimulationException {
    Network network = new NetworkImpl();
    FunctionInput input = new FunctionInput("input", new Function[]{new IdentityFunction(1, 0)}, Units.UNK);
    network.addNode(input);
    NEFEnsembleFactory ef = new NEFEnsembleFactoryImpl();
    int n = 300;
    NEFEnsemble pre = ef.make("pre", n, 2);
    pre.addDecodedTermination("input", MU.uniform(2, 1, 1), .005f, false);
    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);
View Full Code Here

    Network network = new NetworkImpl();
   
    FunctionInput input = new FunctionInput("input", new Function[]{new SineFunction(5)}, Units.UNK);
    network.addNode(input);
   
    NEFEnsembleFactory ef = new NEFEnsembleFactoryImpl();
    NEFEnsemble ensemble = ef.make("ensemble", 100, 1);
    ensemble.addDecodedTermination("input", MU.I(1), .005f, false);
    ensemble.collectSpikes(true);
    network.addNode(ensemble);
   
    network.addProjection(input.getOrigin(FunctionInput.ORIGIN_NAME), ensemble.getTermination("input"));
View Full Code Here

        Plotter.plot(current, 0, dt, T, "current");
        Plotter.plot(pattern);

        //      SigmoidNeuronFactory snf = new SigmoidNeuronFactory(new IndicatorPDF(-10, 10), new IndicatorPDF(-1, 1), new IndicatorPDF(100, 200));
        LinearNeuronFactory lnf = new LinearNeuronFactory(new IndicatorPDF(200, 400), new IndicatorPDF(-1, 1), true);
        NEFEnsembleFactory ef = new NEFEnsembleFactoryImpl();
        ef.setNodeFactory(lnf);

        try {
            NEFEnsemble ensemble = ef.make("test", 20, 1);
            ensemble.addDecodedTermination("input", MU.I(1), .01f, false);
            Plotter.plot(ensemble);

            Network network = new NetworkImpl();
            network.addNode(ensemble);
View Full Code Here

    Function f = new ConstantFunction(1, 1f);
//    Function f = new SineFunction();
    FunctionInput input = new FunctionInput("input", new Function[]{f}, Units.UNK);
    network.addNode(input);
   
    NEFEnsembleFactory ef = new NEFEnsembleFactoryImpl();
   
    NEFEnsemble integrator = ef.make("integrator", 500, 1, "integrator1", true)
    network.addNode(integrator);
    integrator.collectSpikes(true);

    Plotter.plot(integrator);
    Plotter.plot(integrator, NEFEnsemble.X);
View Full Code Here

 
  public static void rasterMemoryTest() {
    try {
      Network network = new NetworkImpl();
     
      NEFEnsembleFactory ef = new NEFEnsembleFactoryImpl();
      final NEFEnsemble ensemble = ef.make("ensemble", 200, 1);
      ensemble.collectSpikes(true);
      network.addNode(ensemble);
     
      FunctionInput input = new FunctionInput("input", new Function[]{new ConstantFunction(1, 1)}, Units.UNK);
      network.addNode(input);
View Full Code Here

        float[][] transform = new float[10][];
        for(int i = 0; i < transform.length; i++) {
            transform[i] = new float[]{1.0f, 1.0f, 1.0f};
        }

        NEFEnsembleFactoryImpl ef = new NEFEnsembleFactoryImpl();
        NEFEnsembleImpl c = (NEFEnsembleImpl)ef.make("c", 10, 1);

        LinearExponentialTermination[] nodeterms = new LinearExponentialTermination[10];
        for(int i = 0; i < nodeterms.length; i++) {
            nodeterms[i] = new LinearExponentialTermination(new SpikingNeuron(null, null, 0.0f, 0.0f, null), null, transform[i], 0.0f);
        }
View Full Code Here

        {
            transform[i] = new float[]{1.0f, 1.0f, 1.0f};
            newtransform[i] = new float[]{0.0f, 0.0f, 0.0f};
        }

        NEFEnsembleFactoryImpl ef = new NEFEnsembleFactoryImpl();
        NEFEnsembleImpl c = (NEFEnsembleImpl)ef.make("c", 10, 1);

        LinearExponentialTermination[] nodeterms = new LinearExponentialTermination[10];
        for(int i = 0; i < nodeterms.length; i++) {
            nodeterms[i] = new LinearExponentialTermination(new SpikingNeuron(null, null, 0.0f, 0.0f, null), null, transform[i], 0.0f);
        }
View Full Code Here

TOP

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

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.