Package ca.nengo.util

Examples of ca.nengo.util.Probe


    /*
     * Creates the probe
     */
    Node node = nodeAttachedTo.getModel();
    Probe probe;
    try {
      if (nodeAttachedTo.getParentViewer() instanceof EnsembleViewer) {
        EnsembleViewer ensembleViewer = (EnsembleViewer) nodeAttachedTo.getParentViewer();

        UIEnsemble ensemble = ensembleViewer.getViewerParent();
View Full Code Here


  protected void prepareToDestroyModel() {
    try {
      getProbeParent().getNetworkParent().getSimulator().removeProbe(getModel());
      getProbeParent().showPopupMessage("Probe removed from Simulator");
     
      Probe model = getModel();
      if(model.isInEnsemble()){
        Ensemble target = (Ensemble) model.getTarget();
        target.stopProbing(model.getStateName());
      }
    } catch (SimulationException e) {
      UserMessages.showError("Could not remove probe: " + e.getMessage());
    }
View Full Code Here

                    throw new SimulationException("A probe already exists on this target & state");
                }
            }
        }

        Probe result = new ProbeImpl();
        result.connect(ensembleName, target, state, record);
       
        myProbeTasks.add(result.getProbeTask());
        myProbes.add(result);

        fireVisibleChangeEvent();
        return result;
    }
View Full Code Here

    NEFEnsemble ensemble = factory.make("Ensemble",100,2);
    File file = new File("testWTDSL.csv");
   
    network.addNode(ensemble);
   
    Probe probe = network.getSimulator().addProbe("Ensemble", "X", true);
    WriteToDiskSimulatorListener listener = new WriteToDiskSimulatorListener(file,probe,0.005f);
   
    network.getSimulator().addSimulatorListener(listener);
    network.getSimulator().run(0.0f, 1.0f, 0.001f);
   
View Full Code Here

    network.addNode(ensemble);
   
    float interval = 0.005f;
    float simLength = 1.0f;
    int numIntervals = (int)(simLength / interval);
    Probe probe = network.getSimulator().addProbe("Ensemble", "X", true);
    WriteToDiskSimulatorListener listener = new WriteToDiskSimulatorListener(file,probe,interval);
       
    network.getSimulator().addSimulatorListener(listener);
    network.getSimulator().run(0.0f, simLength, 0.001f);
   
View Full Code Here

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

            FunctionInput input = new FunctionInput("input", new Function[]{new SineFunction(3)}, Units.UNK);
            network.addNode(input);
            network.addProjection(input.getOrigin(FunctionInput.ORIGIN_NAME), ensemble.getTermination("input"));

            network.setMode(SimulationMode.RATE);
            Probe rates = network.getSimulator().addProbe("test", "rate", true);
            network.run(0, 2);
            //          Plotter.plot(rates.getData(), .05f, "rates");
            Plotter.plot(rates.getData(), "rates");
        } catch (StructuralException e) {
            e.printStackTrace();
        } catch (SimulationException e) {
            e.printStackTrace();
        }
View Full Code Here

       
    try {
      Network network = createNetwork();
      Simulator simulator = network.getSimulator();
     
      Probe inputRecorder = simulator.addProbe("input", "input", true);
      Probe integratorRecorder = simulator.addProbe("integrator", NEFEnsemble.X, true);
      Probe neuronRecorder = simulator.addProbe("integrator", 0, "V", true);

      long startTime = System.currentTimeMillis();
      simulator.run(0f, 1f, .0002f);
      System.out.println("Run time: " + ((System.currentTimeMillis() - startTime)/1000f) );
   
      TimeSeries integratorData = integratorRecorder.getData();
      integratorData.getLabels()[0] = "decoded output";
     
      Plotter.plot(inputRecorder.getData(), "Input");
      Plotter.plot(integratorData, .005f, "Integrator");
      Plotter.plot(neuronRecorder.getData(), "Neuron #0");
     
      Plotter.plot(((Ensemble) network.getNode("integrator")).getSpikePattern());
     
      MatlabExporter me = new MatlabExporter();
      me.add("input", inputRecorder.getData());
      me.add("integrator", integratorRecorder.getData(), .01f);
      me.add("neuron", neuronRecorder.getData());
      me.write(new File("export.mat"));
     
    } catch (SimulationException e) {
      e.printStackTrace();
    } catch (StructuralException e) {
View Full Code Here

      String name = "functions of time";
      FunctionInput fi = new FunctionInput(name, funcs, Units.uAcm2);
      network.addNode(fi);
     
      //we can add a probe to it and run the simulator ...
      Probe p = network.getSimulator().addProbe(name, FunctionInput.STATE_NAME, true);     
      network.run(0, 10);
     
      JFrame frame = makeAnimPlotFrame("vector plot");
      frame.setLayout(new BorderLayout());
      Scope scope = new Scope(p);
      frame.getContentPane().add(scope.getGraphPanel(), BorderLayout.CENTER);
      frame.getContentPane().add(scope.getCtrlPanel(), BorderLayout.SOUTH);
      //frame.setSize(900, 600);
      frame.pack();
      frame.setLocationRelativeTo(null);

      //... and plot the probed data from the simulation ...
      //Plotter.plot(p.getData(), "function output");
     
      //now here are a couple of function bases ...
      Function g1 = new GaussianPDF(0, 1);
      Function g2 = new GaussianPDF(0.5f, 1);     
      FunctionBasis gaussianBasis = new FunctionBasisImpl(new Function[]{g1, g2});
     
      //here is a plot of the probed vector X the gaussian basis (value at time 4.5s) ...      
      gaussianBasis.setCoefficients(p.getData().getValues()[4500]);
      //Plotter.plot(gaussianBasis, -3, .001f, 3, "gaussian basis plot");
     
     
      Function s1 = new SigmoidFunction(0, 1, 0, 1);
      Function s2 = new SigmoidFunction(0.5f, -1, 0, 1);
      FunctionBasis sigmoidBasis = new FunctionBasisImpl(new Function[]{s1, s2});
     
      //here is a plot of the probed vector X the sigmoid basis (value at time 0.5s) ...            
      sigmoidBasis.setCoefficients(p.getData().getValues()[500]);
      //Plotter.plot(sigmoidBasis, -3, .001f, 3, "sigmoid basis plot");
     
    } catch (StructuralException e) {
      e.printStackTrace();
    } catch (SimulationException e) {
View Full Code Here

    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");
    Plotter.plot(pInter.getData(), .01f, "interneurons");

   
   
//    //remove negative weights ...
//    BiasOrigin bo = pre.addBiasOrigin(baseOrigin, 100, "interneurons", true);
View Full Code Here

TOP

Related Classes of ca.nengo.util.Probe

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.