Package ca.nengo.util.impl

Examples of ca.nengo.util.impl.RandomHypersphereVG


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


   * Test method for 'ca.nengo.util.impl.RandomHypersphereVG.genVectors(int, int)'
   */
  public void testGenVectors() {
    VectorGenerator vg = null;
   
    vg = new RandomHypersphereVG(true, 1f, 1f);
    float[][] v = vg.genVectors(10, 3);
    for (int i = 0; i < v.length; i++) {
      float radius = (float) Math.pow(v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2], .5);
      TestUtil.assertClose(1f, radius, .0001f);
    }

    vg = new RandomHypersphereVG(true, 1f, 0f);
    v = vg.genVectors(10, 3);
    for (int i = 0; i < v.length; i++) {
      float radius = (float) Math.pow(v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2], .5);
      TestUtil.assertClose(1f, radius, .0001f);
    }

    vg = new RandomHypersphereVG(true, 1f, .5f);
    v = vg.genVectors(10, 3);
    for (int i = 0; i < v.length; i++) {
      float radius = (float) Math.pow(v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2], .5);
      TestUtil.assertClose(1f, radius, .0001f);
    }
   
    vg = new RandomHypersphereVG(false, 1f, 1f);
    v = vg.genVectors(10, 3);
    for (int i = 0; i < v.length; i++) {
      float radius = (float) Math.pow(v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2], .5);
      assertTrue(radius < 1f);
    }
   
    vg = new RandomHypersphereVG(true, 2f, 1f);
    v = vg.genVectors(10, 3);
    for (int i = 0; i < v.length; i++) {
      float radius = (float) Math.pow(v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2], .5);
      TestUtil.assertClose(2f, radius, .0001f);
    }

    vg = new RandomHypersphereVG(true, 1f, 1f);
    v = vg.genVectors(10, 3);
    for (int i = 0; i < v.length; i++) {
      TestUtil.assertClose(1f, Math.abs(v[i][0]) + Math.abs(v[i][1]) + Math.abs(v[i][2]), .0001f);
    }
  }
View Full Code Here

    /**
     * @param radius Radius
     */
    public void setRadius(float radius) {
      myRadius = radius;
      myVG = new RandomHypersphereVG(false, radius, 1);
    }
View Full Code Here

    /**
     * @param radius Radius
     */
    public void setRadius(float radius) {
      myRadius = radius;
      myVG = new RandomHypersphereVG(true, radius, 1);
    }
View Full Code Here

  /**
   * Default constructor. Sets up factories.
   */
  public NEFEnsembleFactoryImpl() {
    myApproximatorFactory = new WeightedCostApproximator.Factory(0.1f);
    myEncoderFactory = new RandomHypersphereVG(true, 1f, 0f);
    myEvalPointFactory = new RandomHypersphereVG(false, 1f, 0f);
    myNodeFactory = new LIFNeuronFactory(.02f, .002f, new IndicatorPDF(200f, 400f), new IndicatorPDF(-.9f, .9f));
  }
View Full Code Here

    NEFEnsembleFactory ef = new NEFEnsembleFactoryImpl() {
      private static final long serialVersionUID = 1L;
      protected void addDefaultOrigins(NEFEnsemble ensemble) {} //wait until some neurons are adjusted
    };
    ef.setEncoderFactory(new Rectifier(ef.getEncoderFactory(), true));
    ef.setEvalPointFactory(new BiasedVG(new RandomHypersphereVG(false, 0.5f, 0f), 0, excitatoryProjection ? .5f : -.5f));

//    PDF interceptPDF = excitatoryProjection ? new IndicatorPDF(-.5f, .75f) : new IndicatorPDF(-.99f, .35f);
    PDF interceptPDF = excitatoryProjection ? new IndicatorPDF(-.15f, .9f) : new IndicatorPDF(-1.2f, .1f); //was -.5f, .75f for excitatory
    PDF maxRatePDF = excitatoryProjection ? new IndicatorPDF(200f, 500f) : new IndicatorPDF(400f, 800f);
    ef.setNodeFactory(new LIFNeuronFactory(.02f, .0001f, maxRatePDF, interceptPDF));
View Full Code Here

    float[] result = new float[getDimensions()];

    if (myNode instanceof NEFEnsemble) {
      NEFEnsemble ensemble = (NEFEnsemble) myNode;

      VectorGenerator vg = new RandomHypersphereVG(false, 1, 0);
      float[][] unscaled = vg.genVectors(samples, ensemble.getDimension());
      float[][] input = new float[unscaled.length][];
      for (int i = 0; i < input.length; i++) {
        input[i] = MU.prodElementwise(unscaled[i], ensemble.getRadii());
      }
View Full Code Here

TOP

Related Classes of ca.nengo.util.impl.RandomHypersphereVG

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.