Examples of VectorGenerator


Examples of ca.nengo.util.VectorGenerator

            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

Examples of ca.nengo.util.VectorGenerator

  /*
   * 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

Examples of ca.nengo.util.VectorGenerator

    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
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.