Java Code Examples for org.numenta.nupic.encoders.ScalarEncoder#Builder
The following examples show how to use
org.numenta.nupic.encoders.ScalarEncoder#Builder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NetworkConsistencyTest.java From htm.java with GNU Affero General Public License v3.0 | 6 votes |
public SimpleLayer() { params = getParameters(); ScalarEncoder.Builder dayBuilder = ScalarEncoder.builder() .n(8) .w(3) .radius(1.0) .minVal(1.0) .maxVal(8) .periodic(true) .forced(true) .resolution(1); encoder = dayBuilder.build(); spatialPooler = new SpatialPooler(); temporalMemory = new TemporalMemory(); Map<String, Object> anomalyParams = new HashMap<>(); anomalyParams.put(KEY_MODE, Mode.PURE); anomaly = Anomaly.create(anomalyParams); configure(); }
Example 2
Source File: QuickTest.java From htm.java-examples with GNU Affero General Public License v3.0 | 5 votes |
/** * @param args the command line arguments */ public static void main(String[] args) { Parameters params = getParameters(); System.out.println(params); // Toggle this to switch between resetting on every week start day isResetting = true; //Layer components ScalarEncoder.Builder dayBuilder = ScalarEncoder.builder() .n(8) .w(3) .radius(1.0) .minVal(1.0) .maxVal(8) .periodic(true) .forced(true) .resolution(1); ScalarEncoder encoder = dayBuilder.build(); SpatialPooler sp = new SpatialPooler(); TemporalMemory tm = new TemporalMemory(); CLAClassifier classifier = new CLAClassifier(new TIntArrayList(new int[] { 1 }), 0.1, 0.3, 0); Layer<Double> layer = getLayer(params, encoder, sp, tm, classifier); for(double i = 0, x = 0, j = 0;j < 1500;j = (i == 6 ? j + 1: j), i = (i == 6 ? 0 : i + 1), x++) { // USE "X" here to control run length if (i == 0 && isResetting) { System.out.println("reset:"); tm.reset(layer.getMemory()); } // For 3rd argument: Use "i" for record num if re-cycling records (isResetting == true) - otherwise use "x" (the sequence number) runThroughLayer(layer, i + 1, isResetting ? (int)i : (int)x, (int)x); } }
Example 3
Source File: QuickTestTest.java From htm.java-examples with GNU Affero General Public License v3.0 | 5 votes |
@Test public void testRunThroughLayer() { Layer<Double> layer = null; try { Parameters params = QuickTest.getParameters(); //Layer components ScalarEncoder.Builder dayBuilder = ScalarEncoder.builder() .n(8) .w(3) .radius(1.0) .minVal(1.0) .maxVal(8) .periodic(true) .forced(true) .resolution(1); ScalarEncoder encoder = dayBuilder.build(); SpatialPooler sp = new SpatialPooler(); TemporalMemory tm = new TemporalMemory(); CLAClassifier classifier = new CLAClassifier(new TIntArrayList(new int[] { 1 }), 0.1, 0.3, 0); layer = QuickTest.getLayer(params, encoder, sp, tm, classifier); for(double i = 1, x = 0;x < 10000;i = (i == 7 ? 1 : i + 1), x++) {// USE "X" here to control run length if (i == 1) tm.reset(layer.getMemory()); QuickTest.runThroughLayer(layer, i, (int)i, (int)x); } }catch(Exception e) { e.printStackTrace(); fail(); } System.out.println("actual = " + Arrays.toString(layer.getActual()) + ", predicted = " + Arrays.toString(layer.getPredicted())); //assertArrayEquals(layer.getActual(), layer.getPredicted()); }
Example 4
Source File: AbstractAlgorithmBenchmark.java From htm.java with GNU Affero General Public License v3.0 | 5 votes |
@Setup public void init() { SDR = new int[2048]; //Layer components ScalarEncoder.Builder dayBuilder = ScalarEncoder.builder() .n(8) .w(3) .radius(1.0) .minVal(1.0) .maxVal(8) .periodic(true) .forced(true) .resolution(1); encoder = dayBuilder.build(); pooler = new SpatialPooler(); memory = new Connections(); Parameters params = getParameters(); params.apply(memory); pooler = new SpatialPooler(); pooler.init(memory); temporalMemory = new TemporalMemory(); TemporalMemory.init(memory); }
Example 5
Source File: QuickDayTest.java From htm.java with GNU Affero General Public License v3.0 | 5 votes |
/** * @param args the command line arguments */ public static void main(String[] args) { Parameters params = getParameters(); System.out.println(params); // Toggle this to switch between resetting on every week start day isResetting = true; //Layer components ScalarEncoder.Builder dayBuilder = ScalarEncoder.builder() .n(8) .w(3) .radius(1.0) .minVal(1.0) .maxVal(8) .periodic(true) .forced(true) .resolution(1); ScalarEncoder encoder = dayBuilder.build(); SpatialPooler sp = new SpatialPooler(); TemporalMemory tm = new TemporalMemory(); CLAClassifier classifier = new CLAClassifier(new TIntArrayList(new int[] { 1 }), 0.1, 0.3, 0); Layer<Double> layer = getLayer(params, encoder, sp, tm, classifier); for(double i = 0, x = 0, j = 0;j < 1500;j = (i == 6 ? j + 1: j), i = (i == 6 ? 0 : i + 1), x++) { // USE "X" here to control run length if (i == 0 && isResetting) { System.out.println("reset:"); tm.reset(layer.getMemory()); } // For 3rd argument: Use "i" for record num if re-cycling records (isResetting == true) - otherwise use "x" (the sequence number) runThroughLayer(layer, i + 1, isResetting ? (int)i : (int)x, (int)x); } }