Java Code Examples for org.numenta.nupic.Parameters#empty()
The following examples show how to use
org.numenta.nupic.Parameters#empty() .
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: ExtensiveTemporalMemoryTest.java From htm.java with GNU Affero General Public License v3.0 | 5 votes |
/** * Like B1 but with cellsPerColumn = 4. * First order sequences should still work just fine. */ @Test public void testB5() { Parameters p = Parameters.empty(); p.set(KEY.CELLS_PER_COLUMN, 4); init(p, PATTERN_MACHINE); assertTrue(tm.getConnections().getCellsPerColumn() == 4); // Instead of implementing the Python "shuffle" method, just use the exact output Integer[] shuffledNums = new Integer[] { 83, 53, 70, 45, 44, 39, 22, 80, 10, 0, 18, 30, 73, 33, 90, 4, 76, 77, 12, 31, 55, 88, 26, 42, 69, 15, 40, 96, 9, 72, 11, 47, 85, 28, 93, 5, 66, 65, 35, 16, 49, 34, 7, 95, 27, 19, 81, 25, 62, 13, 24, 3, 17, 38, 8, 78, 6, 64, 36, 89, 56, 99, 54, 43, 50, 67, 46, 68, 61, 97, 79, 41, 58, 48, 98, 57, 75, 32, 94, 59, 63, 84, 37, 29, 1, 52, 21, 2, 23, 87, 91, 74, 86, 82, 20, 60, 71, 14, 92, 51, -1 }; List<Integer> numberList = Arrays.asList(shuffledNums); List<Set<Integer>> sequence = sequenceMachine.generateFromNumbers(numberList); feedTM(sequence, "", true, 1); testTM(sequence, ""); assertAllActiveWerePredicted(); assertAllInactiveWereUnpredicted(); }
Example 2
Source File: ExtensiveTemporalMemoryTest.java From htm.java with GNU Affero General Public License v3.0 | 5 votes |
/** * Like B4 but with cellsPerColumn = 4. * First order sequences should still work just fine. */ @Test public void testB6() { Parameters p = Parameters.empty(); p.set(KEY.CELLS_PER_COLUMN, 4); init(p, PATTERN_MACHINE); assertTrue(tm.getConnections().getCellsPerColumn() == 4); // Instead of implementing the Python "shuffle" method, just use the exact output Integer[] shuffledNums = new Integer[] { 83, 53, 70, 45, 44, 39, 22, 80, 10, 0, 18, 30, 73, 33, 90, 4, 76, 77, 12, 31, 55, 88, 26, 42, 69, 15, 40, 96, 9, 72, 11, 47, 85, 28, 93, 5, 66, 65, 35, 16, 49, 34, 7, 95, 27, 19, 81, 25, 62, 13, 24, 3, 17, 38, 8, 78, 6, 64, 36, 89, 56, 99, 54, 43, 50, 67, 46, 68, 61, 97, 79, 41, 58, 48, 98, 57, 75, 32, 94, 59, 63, 84, 37, 29, 1, 52, 21, 2, 23, 87, 91, 74, 86, 82, 20, 60, 71, 14, 92, 51, -1, 179, 137, 165, 154, 115, 120, 199, 125, 156, 117, 159, 193, 187, 166, 155, 173, 139, 130, 116, 149, 160, 153, 183, 123, 188, 109, 118, 182, 174, 189, 158, 198, 148, 176, 157, 190, 175, 186, 163, 124, 178, 110, 129, 119, 145, 181, 185, 152, 105, 167, 169, 101, 192, 121, 168, 191, 131, 112, 135, 128, 142, 170, 144, 138, 184, 103, 151, 162, 150, 141, 114, 108, 126, 113, 194, 100, 102, 177, 146, 164, 196, 143, 136, 161, 122, 147, 195, 133, 111, 171, 172, 106, 127, 140, 104, 132, 197, 134, 107, 180, -1, 248, 228, 285, 283, 214, 209, 242, 221, 275, 293, 244, 226, 260, 212, 220, 246, 245, 240, 213, 261, 253, 250, 271, 294, 257, 205, 203, 207, 284, 277, 262, 233, 265, 282, 288, 286, 247, 281, 287, 208, 292, 236, 204, 211, 259, 299, 225, 278, 206, 234, 241, 229, 230, 222, 249, 224, 256, 227, 279, 297, 264, 217, 238, 263, 239, 232, 251, 273, 270, 266, 298, 235, 276, 219, 202, 280, 258, 272, 215, 210, 290, 268, 223, 237, 216, 255, 274, 254, 267, 291, 269, 231, 289, 243, 252, 201, 218, 200, 296, 295, -1 }; List<Integer> numberList = Arrays.asList(shuffledNums); List<Set<Integer>> sequence = sequenceMachine.generateFromNumbers(numberList); feedTM(sequence, "", true, 3); testTM(sequence, ""); assertAllActiveWerePredicted(); assertAllInactiveWereUnpredicted(); }
Example 3
Source File: ExtensiveTemporalMemoryTest.java From htm.java with GNU Affero General Public License v3.0 | 5 votes |
/** * Like B1 but with slower learning. * * Set the following parameters differently: * * initialPermanence = 0.2 * connectedPermanence = 0.7 * permanenceIncrement = 0.2 * * Now we train the TP with the B1 sequence 4 times (P=4). This will increment * the permanences to be above 0.8 and at that point the inference will be correct. * This test will ensure the basic match function and segment activation rules are * working correctly. */ @Test public void testB7() { Parameters p = Parameters.empty(); p.set(KEY.INITIAL_PERMANENCE, 0.2); p.set(KEY.CONNECTED_PERMANENCE, 0.7); p.set(KEY.PERMANENCE_INCREMENT, 0.2); init(p, PATTERN_MACHINE); assertTrue(tm.getConnections().getInitialPermanence() == 0.2); assertTrue(tm.getConnections().getConnectedPermanence() == 0.7); assertTrue(tm.getConnections().getPermanenceIncrement() == 0.2); // Instead of implementing the Python "shuffle" method, just use the exact output Integer[] shuffledNums = new Integer[] { 83, 53, 70, 45, 44, 39, 22, 80, 10, 0, 18, 30, 73, 33, 90, 4, 76, 77, 12, 31, 55, 88, 26, 42, 69, 15, 40, 96, 9, 72, 11, 47, 85, 28, 93, 5, 66, 65, 35, 16, 49, 34, 7, 95, 27, 19, 81, 25, 62, 13, 24, 3, 17, 38, 8, 78, 6, 64, 36, 89, 56, 99, 54, 43, 50, 67, 46, 68, 61, 97, 79, 41, 58, 48, 98, 57, 75, 32, 94, 59, 63, 84, 37, 29, 1, 52, 21, 2, 23, 87, 91, 74, 86, 82, 20, 60, 71, 14, 92, 51, -1 }; List<Integer> numberList = Arrays.asList(shuffledNums); List<Set<Integer>> sequence = sequenceMachine.generateFromNumbers(numberList); for(int i = 0;i < 4;i++) { feedTM(sequence, "", true, 1); } testTM(sequence, ""); assertAllActiveWerePredicted(); assertAllInactiveWereUnpredicted(); }
Example 4
Source File: ExtensiveTemporalMemoryTest.java From htm.java with GNU Affero General Public License v3.0 | 5 votes |
/** * Like B7 but with 4 cells per column. * Should still work. */ @Test public void testB8() { Parameters p = Parameters.empty(); p.set(KEY.INITIAL_PERMANENCE, 0.2); p.set(KEY.CONNECTED_PERMANENCE, 0.7); p.set(KEY.PERMANENCE_INCREMENT, 0.2); p.set(KEY.CELLS_PER_COLUMN, 4); init(p, PATTERN_MACHINE); assertTrue(tm.getConnections().getInitialPermanence() == 0.2); assertTrue(tm.getConnections().getConnectedPermanence() == 0.7); assertTrue(tm.getConnections().getPermanenceIncrement() == 0.2); assertTrue(tm.getConnections().getCellsPerColumn() == 4); // Instead of implementing the Python "shuffle" method, just use the exact output Integer[] shuffledNums = new Integer[] { 83, 53, 70, 45, 44, 39, 22, 80, 10, 0, 18, 30, 73, 33, 90, 4, 76, 77, 12, 31, 55, 88, 26, 42, 69, 15, 40, 96, 9, 72, 11, 47, 85, 28, 93, 5, 66, 65, 35, 16, 49, 34, 7, 95, 27, 19, 81, 25, 62, 13, 24, 3, 17, 38, 8, 78, 6, 64, 36, 89, 56, 99, 54, 43, 50, 67, 46, 68, 61, 97, 79, 41, 58, 48, 98, 57, 75, 32, 94, 59, 63, 84, 37, 29, 1, 52, 21, 2, 23, 87, 91, 74, 86, 82, 20, 60, 71, 14, 92, 51, -1 }; List<Integer> numberList = Arrays.asList(shuffledNums); List<Set<Integer>> sequence = sequenceMachine.generateFromNumbers(numberList); for(int i = 0;i < 4;i++) { feedTM(sequence, "", true, 1); } testTM(sequence, ""); assertAllActiveWerePredicted(); assertAllInactiveWereUnpredicted(); }
Example 5
Source File: ExtensiveTemporalMemoryTest.java From htm.java with GNU Affero General Public License v3.0 | 5 votes |
/** * Like B7 but present the sequence less than 4 times. * The inference should be incorrect. */ @Test public void testB9() { Parameters p = Parameters.empty(); p.set(KEY.INITIAL_PERMANENCE, 0.2); p.set(KEY.CONNECTED_PERMANENCE, 0.7); p.set(KEY.PERMANENCE_INCREMENT, 0.2); init(p, PATTERN_MACHINE); assertTrue(tm.getConnections().getInitialPermanence() == 0.2); assertTrue(tm.getConnections().getConnectedPermanence() == 0.7); assertTrue(tm.getConnections().getPermanenceIncrement() == 0.2); assertTrue(tm.getConnections().getCellsPerColumn() == 1); // Instead of implementing the Python "shuffle" method, just use the exact output Integer[] shuffledNums = new Integer[] { 83, 53, 70, 45, 44, 39, 22, 80, 10, 0, 18, 30, 73, 33, 90, 4, 76, 77, 12, 31, 55, 88, 26, 42, 69, 15, 40, 96, 9, 72, 11, 47, 85, 28, 93, 5, 66, 65, 35, 16, 49, 34, 7, 95, 27, 19, 81, 25, 62, 13, 24, 3, 17, 38, 8, 78, 6, 64, 36, 89, 56, 99, 54, 43, 50, 67, 46, 68, 61, 97, 79, 41, 58, 48, 98, 57, 75, 32, 94, 59, 63, 84, 37, 29, 1, 52, 21, 2, 23, 87, 91, 74, 86, 82, 20, 60, 71, 14, 92, 51, -1 }; List<Integer> numberList = Arrays.asList(shuffledNums); List<Set<Integer>> sequence = sequenceMachine.generateFromNumbers(numberList); for(int i = 0;i < 3;i++) { feedTM(sequence, "", true, 1); } testTM(sequence, ""); assertAllActiveWereUnpredicted(); }
Example 6
Source File: ExtensiveTemporalMemoryTest.java From htm.java with GNU Affero General Public License v3.0 | 5 votes |
/** * Same as H1, but with cellsPerColumn == 4, and train multiple times. * It should make just the right number of predictions. */ @Test public void testH2() { Parameters p = Parameters.empty(); p.set(KEY.CELLS_PER_COLUMN, 4); init(p, PATTERN_MACHINE); // Instead of implementing the Python "shuffle" method, just use the exact output Integer[] shuffledNums = new Integer[] { 0, 17, 15, 1, 8, 5, 11, 3, 18, 16, 40, 41, 42, 43, 44, 12, 7, 10, 14, 6, -1, 39, 36, 35, 25, 24, 32, 34, 27, 23, 26, 40, 41, 42, 43, 44, 28, 37, 31, 20, 21, -1 }; List<Integer> numberList = Arrays.asList(shuffledNums); List<Set<Integer>> sequence = sequenceMachine.generateFromNumbers(numberList); for(int i = 0;i < 10;i++) { feedTM(sequence, "", true, 1); } testTM(sequence, ""); assertAllActiveWerePredicted(); // Without some kind of decay, expect predicted inactive columns at the // end of the first shared sequence IndicesTrace predictedInactiveTrace = tm.mmGetTracePredictedInactiveColumns(); Metric predictedInactiveColumnsMetric = tm.mmGetMetricFromTrace(predictedInactiveTrace); assertTrue(predictedInactiveColumnsMetric.mean > 0); assertTrue(predictedInactiveColumnsMetric.sum < 26); // At the end of the second shared sequence, there should be no // predicted but inactive columns assertTrue(tm.mmGetTracePredictedInactiveColumns().items.get(36).size() == 0); }
Example 7
Source File: ExtensiveTemporalMemoryTest.java From htm.java with GNU Affero General Public License v3.0 | 5 votes |
/** * Like H2, except the shared subsequence is in the beginning. * (e.g. "ABCDEF" and "ABCGHIJ") At the point where the shared subsequence * ends, all possible next patterns should be predicted. As soon as you see * the first unique pattern, the predictions should collapse to be a perfect * prediction. */ @Test public void testH3() { Parameters p = Parameters.empty(); p.set(KEY.CELLS_PER_COLUMN, 4); init(p, PATTERN_MACHINE); // Instead of implementing the Python "shuffle" method, just use the exact output Integer[] shuffledNums = new Integer[] { 40, 41, 42, 43, 44, 5, 11, 3, 18, 16, 13, 2, 9, 19, 4, 12, 7, 10, 14, 6, -1, 40, 41, 42, 43, 44, 32, 34, 27, 23, 26, 22, 29, 33, 30, 38, 28, 37, 31, 20, 21, -1 }; List<Integer> numberList = Arrays.asList(shuffledNums); List<Set<Integer>> sequence = sequenceMachine.generateFromNumbers(numberList); feedTM(sequence, "", true, 1); testTM(sequence, ""); assertAllActiveWerePredicted(); // Without some kind of decay, expect predicted inactive columns at the // end of the first shared sequence IndicesTrace predictedInactiveTrace = tm.mmGetTracePredictedInactiveColumns(); Metric predictedInactiveColumnsMetric = tm.mmGetMetricFromTrace(predictedInactiveTrace); assertTrue(predictedInactiveColumnsMetric.mean > 0); assertTrue(predictedInactiveColumnsMetric.sum < 26 * 2); // At the end of the second shared sequence, there should be // predicted but inactive columns int i = 0; for(Set<Integer> s : tm.mmGetTracePredictedInactiveColumns().items) { System.out.println("" + (i++) + " " + s); } assertTrue(tm.mmGetTracePredictedInactiveColumns().items.get(4).size() > 0); assertTrue(tm.mmGetTracePredictedInactiveColumns().items.get(23).size() > 0); }
Example 8
Source File: ExtensiveTemporalMemoryTest.java From htm.java with GNU Affero General Public License v3.0 | 5 votes |
/** * Shared patterns. Similar to H2 except that patterns are shared between * sequences. All sequences are different shufflings of the same set of N * patterns (there is no shared subsequence). */ @Test public void testH4() { Parameters p = Parameters.empty(); p.set(KEY.CELLS_PER_COLUMN, 4); init(p, PATTERN_MACHINE); // Instead of implementing the Python "shuffle" method, just use the exact output Integer[] shuffledNums = new Integer[] { 0, 17, 15, 1, 8, 5, 11, 3, 18, 16, 13, 2, 9, 19, 4, 12, 7, 10, 14, 6, -1, 19, 16, 15, 5, 4, 12, 14, 7, 3, 6, 2, 9, 13, 10, 18, 8, 17, 11, 0, 1, -1 }; List<Integer> numberList = Arrays.asList(shuffledNums); List<Set<Integer>> sequence = sequenceMachine.generateFromNumbers(numberList); for(int i = 0;i < 20;i++) { feedTM(sequence, "", true, 1); } testTM(sequence, ""); assertAllActiveWerePredicted(); IndicesTrace predictedInactiveTrace = tm.mmGetTracePredictedInactiveColumns(); Metric predictedInactiveColumnsMetric = tm.mmGetMetricFromTrace(predictedInactiveTrace); assertTrue(predictedInactiveColumnsMetric.mean < 3); }
Example 9
Source File: ExtensiveTemporalMemoryTest.java From htm.java with GNU Affero General Public License v3.0 | 5 votes |
/** * Combination of H4) and H2). * Shared patterns in different sequences, with a shared subsequence. */ @Test public void testH5() { Parameters p = Parameters.empty(); p.set(KEY.CELLS_PER_COLUMN, 4); init(p, PATTERN_MACHINE); // Instead of implementing the Python "shuffle" method, just use the exact output Integer[] shuffledNums = new Integer[] { 8, 16, 18, 11, 9, 13, 14, 5, 12, 15, 1, 4, 2, 0, 3, 19, 17, 10, 6, 7, -1, 17, 5, 10, 7, 12, 8, 6, 13, 14, 18, 1, 4, 2, 0, 3, 15, 9, 16, 19, 11, -1 }; List<Integer> numberList = Arrays.asList(shuffledNums); List<Set<Integer>> sequence = sequenceMachine.generateFromNumbers(numberList); for(int i = 0;i < 20;i++) { feedTM(sequence, "", true, 1); } testTM(sequence, ""); assertAllActiveWerePredicted(); IndicesTrace predictedInactiveTrace = tm.mmGetTracePredictedInactiveColumns(); Metric predictedInactiveColumnsMetric = tm.mmGetMetricFromTrace(predictedInactiveTrace); assertTrue(predictedInactiveColumnsMetric.mean < 3); }
Example 10
Source File: HTMSensorTest.java From htm.java with GNU Affero General Public License v3.0 | 5 votes |
private Parameters getArrayTestParams() { Map<String, Map<String, Object>> fieldEncodings = setupMap( null, 884, // n 0, // w 0, 0, 0, 0, null, null, null, "sdr_in", "darr", "SDRPassThroughEncoder"); Parameters p = Parameters.empty(); p.set(KEY.FIELD_ENCODING_MAP, fieldEncodings); return p; }
Example 11
Source File: LayerTest.java From htm.java with GNU Affero General Public License v3.0 | 5 votes |
private Parameters getArrayTestParams() { Map<String, Map<String, Object>> fieldEncodings = setupMap( null, 884, // n 0, // w 0, 0, 0, 0, null, null, null, "sdr_in", "darr", "SDRPassThroughEncoder"); Parameters p = Parameters.empty(); p.set(KEY.FIELD_ENCODING_MAP, fieldEncodings); return p; }
Example 12
Source File: ExtensiveTemporalMemoryTest.java From htm.java with GNU Affero General Public License v3.0 | 4 votes |
/** * Sensitivity to small amounts of spatial noise during inference * (X = 0.05). Parameters the same as B11, and sequences like H2. */ @Test public void testH9() { Parameters p = Parameters.empty(); p.set(KEY.CELLS_PER_COLUMN, 4); p.set(KEY.ACTIVATION_THRESHOLD, 8); init(p, PATTERN_MACHINE); // Instead of implementing the Python "shuffle" method, just use the exact output Integer[] shuffledNums = new Integer[] { 0, 17, 15, 1, 8, 5, 11, 3, 18, 16, 40, 41, 42, 43, 44, 12, 7, 10, 14, 6, -1, 39, 36, 35, 25, 24, 32, 34, 27, 23, 26, 40, 41, 42, 43, 44, 28, 37, 31, 20, 21, -1 }; List<Integer> numberList = Arrays.asList(shuffledNums); List<Set<Integer>> sequence = sequenceMachine.generateFromNumbers(numberList); for(int i = 0;i < 10;i++) { feedTM(sequence, "", true, 1); } sequence = translateSequence( "set([0, 4, 10, 18, 22, 26, 30, 31, 33, 44, 45, 53, 55, 70, 72, 73, 76, 77, 80, 83, 87, 88, 90]), " + "set([35, 4, 6, 41, 43, 76, 77, 78, 47, 48, 67, 21, 86, 23, 55, 58, 27, 92, 60, 94, 95]), " + "set([1, 10, 13, 17, 18, 19, 28, 30, 31, 35, 36, 37, 44, 53, 66, 71, 75, 80, 81, 84, 86, 90]), " + "set([2, 4, 6, 8, 11, 13, 15, 16, 23, 29, 38, 42, 46, 48, 51, 55, 56, 59, 65, 67, 76, 77, 78, 82, 89]), " + "set([2, 6, 8, 13, 15, 16, 27, 33, 37, 41, 48, 52, 61, 62, 64, 68, 73, 74, 75, 79, 89, 91, 96, 98]), " + "set([0, 4, 5, 9, 12, 17, 25, 34, 38, 39, 41, 42, 44, 56, 65, 68, 69, 74, 76, 77, 83, 88, 93, 96, 99]), " + "set([4, 18, 20, 21, 25, 35, 36, 38, 44, 50, 51, 59, 60, 62, 63, 73, 75, 79, 85, 89, 93, 97]), " + "set([3, 4, 5, 9, 11, 13, 16, 19, 21, 22, 24, 48, 49, 60, 61, 65, 66, 69, 70, 78, 85, 87, 96]), " + "set([4, 7, 11, 12, 14, 19, 20, 23, 26, 27, 31, 35, 40, 50, 54, 56, 58, 65, 75, 81, 84, 85, 87, 97, 98]), " + "set([3, 9, 17, 19, 23, 27, 29, 30, 32, 35, 36, 40, 52, 53, 56, 58, 63, 67, 79, 83, 85, 88, 90, 95]), " + "set([0, 64, 2, 99, 4, 38, 39, 77, 45, 78, 93, 18, 52, 85, 86, 87, 57, 90, 84, 61, 63]), " + "set([0, 1, 4, 6, 10, 11, 15, 18, 22, 30, 37, 43, 44, 47, 53, 58, 60, 61, 69, 74, 75, 78, 80, 90, 94]), " + "set([3, 6, 9, 12, 18, 19, 21, 22, 29, 34, 39, 42, 45, 54, 61, 62, 65, 66, 74, 80, 91, 97, 99]), " + "set([0, 1, 10, 11, 22, 30, 36, 44, 47, 49, 53, 56, 57, 58, 65, 66, 75, 76, 84, 85, 90, 95, 98]), " + "set([96, 1, 67, 35, 36, 37, 73, 42, 77, 61, 80, 92, 19, 98, 25, 26, 59, 60, 29, 95]), " + "set([1, 34, 59, 36, 38, 6, 71, 8, 2, 12, 66, 14, 45, 49, 82, 54, 56, 26, 47, 60, 61]), " + "set([15, 18, 22, 23, 27, 29, 32, 33, 35, 39, 40, 42, 44, 53, 58, 69, 79, 80, 83, 86, 91, 95, 97]), " + "set([4, 5, 7, 11, 14, 16, 40, 45, 46, 47, 53, 58, 60, 67, 69, 71, 73, 75, 77, 79, 85, 86, 89, 92]), " + "set([96, 2, 3, 4, 40, 73, 12, 78, 47, 16, 50, 51, 90, 46, 86, 26, 44, 28, 61, 30, 95]), " + "set([1, 3, 14, 17, 19, 25, 26, 27, 28, 35, 36, 48, 49, 55, 58, 67, 69, 72, 77, 80, 85, 93, 98]), None, " + "set([3, 17, 18, 21, 24, 27, 34, 35, 37, 40, 44, 47, 50, 58, 59, 60, 62, 64, 66, 69, 77, 79, 82, 95, 98]), " + "set([97, 99, 37, 70, 40, 74, 44, 14, 80, 56, 82, 84, 86, 72, 24, 25, 58, 60, 93, 30, 63]), " + "set([5, 6, 8, 12, 17, 24, 25, 29, 31, 33, 35, 41, 46, 53, 56, 57, 63, 67, 68, 71, 78, 83, 88]), " + "set([1, 2, 3, 4, 8, 9, 13, 22, 25, 32, 36, 37, 46, 49, 52, 53, 56, 61, 64, 84, 90, 91, 93, 96]), " + "set([3, 12, 13, 16, 18, 20, 24, 26, 30, 31, 35, 38, 42, 50, 52, 54, 55, 56, 59, 60, 61, 67, 77, 79, 98]), " + "set([5, 7, 15, 22, 23, 25, 27, 40, 42, 47, 49, 50, 56, 58, 59, 62, 69, 77, 82, 89, 92, 96]), " + "set([1, 17, 21, 24, 28, 31, 33, 34, 37, 39, 45, 53, 54, 58, 59, 66, 74, 76, 80, 86, 88, 93, 97]), " + "set([0, 1, 2, 6, 7, 9, 13, 20, 28, 29, 30, 46, 47, 51, 55, 58, 60, 66, 69, 87, 94, 97]), " + "set([1, 7, 12, 13, 22, 25, 26, 31, 38, 40, 44, 58, 61, 62, 67, 70, 71, 73, 84, 85, 92, 97, 98]), " + "set([0, 64, 34, 99, 69, 6, 39, 11, 44, 77, 78, 81, 82, 20, 22, 55, 23, 52, 95, 62, 31]), " + "set([0, 64, 2, 99, 4, 38, 70, 39, 45, 78, 50, 18, 52, 85, 87, 57, 90, 95, 84, 93, 63]), " + "set([4, 6, 8, 10, 11, 18, 22, 23, 30, 35, 37, 43, 44, 47, 53, 58, 60, 61, 66, 69, 74, 75, 80, 90, 94]), " + "set([3, 9, 18, 19, 21, 28, 29, 34, 39, 42, 45, 54, 61, 62, 65, 66, 72, 74, 80, 91, 95, 97]), " + "set([0, 1, 10, 11, 22, 25, 30, 44, 47, 53, 56, 57, 59, 65, 66, 75, 76, 84, 85, 86, 90, 95, 98]), " + "set([5, 13, 18, 19, 23, 25, 26, 29, 35, 36, 37, 42, 48, 57, 59, 60, 67, 77, 92, 95, 96, 98]), " + "set([6, 10, 19, 25, 29, 33, 34, 40, 41, 43, 46, 58, 65, 71, 75, 77, 78, 79, 84, 91, 92, 93, 99]), " + "set([1, 4, 8, 9, 12, 13, 15, 24, 29, 35, 45, 49, 51, 55, 56, 58, 59, 64, 65, 67, 72, 78, 82, 86, 91]), " + "set([5, 6, 7, 11, 17, 22, 23, 25, 27, 28, 30, 35, 38, 42, 52, 66, 67, 68, 75, 78, 82, 87, 88, 93, 99]), " + "set([4, 10, 29, 36, 43, 44, 50, 51, 57, 58, 62, 63, 64, 66, 72, 75, 78, 80, 86, 91, 97, 99]), " + "set([6, 10, 21, 24, 26, 30, 36, 45, 47, 59, 62, 67, 68, 70, 72, 75, 80, 81, 83, 91, 92, 95, 96])"); testTM(sequence, ""); IndicesTrace unpredictedActiveTrace = tm.mmGetTraceUnpredictedActiveColumns(); Metric predictedInactiveColumnsMetric = tm.mmGetMetricFromTrace(unpredictedActiveTrace); assertTrue(predictedInactiveColumnsMetric.mean < 3); }
Example 13
Source File: ExtensiveTemporalMemoryTest.java From htm.java with GNU Affero General Public License v3.0 | 4 votes |
/** * Orphan Decay mechanism reduce predicted inactive cells (extra predictions). * Test feeds in noisy sequences (X = 0.05) to TM with and without orphan decay. * TM with orphan decay should has many fewer predicted inactive columns. * Parameters the same as B11, and sequences like H9. */ @Test public void testH10() { // train TM on noisy sequences with orphan decay turned off Parameters p = Parameters.empty(); p.set(KEY.CELLS_PER_COLUMN, 4); p.set(KEY.ACTIVATION_THRESHOLD, 8); init(p, PATTERN_MACHINE); assertTrue(tm.getConnections().getPredictedSegmentDecrement() == 0); // Instead of implementing the Python "shuffle" method, just use the exact output Integer[] shuffledNums = new Integer[] { 0, 17, 15, 1, 8, 5, 11, 3, 18, 16, 40, 41, 42, 43, 44, 12, 7, 10, 14, 6, -1, 39, 36, 35, 25, 24, 32, 34, 27, 23, 26, 40, 41, 42, 43, 44, 28, 37, 31, 20, 21, -1 }; List<Integer> numberList = Arrays.asList(shuffledNums); List<Set<Integer>> sequence = sequenceMachine.generateFromNumbers(numberList); List<List<Set<Integer>>> sequenceNoisy = new ArrayList<>(); for(int i = 0;i < 10;i++) { sequenceNoisy.add(sequenceMachine.addSpatialNoise(sequence, 0.05)); feedTM(sequenceNoisy.get(i), "", true, 1); } testTM(sequence, ""); IndicesTrace predictedInactiveTrace = tm.mmGetTracePredictedInactiveColumns(); Metric predictedInactiveColumnsMetric = tm.mmGetMetricFromTrace(predictedInactiveTrace); double predictedInactiveColumnsMean1 = predictedInactiveColumnsMetric.mean; p = Parameters.empty(); p.set(KEY.CELLS_PER_COLUMN, 4); p.set(KEY.ACTIVATION_THRESHOLD, 8); p.set(KEY.PREDICTED_SEGMENT_DECREMENT, 0.04); init(p, PATTERN_MACHINE); assertTrue(tm.getConnections().getPredictedSegmentDecrement() == 0.04); for(int i = 0;i < 10;i++) { feedTM(sequenceNoisy.get(0), "", true, 1); } testTM(sequence, ""); predictedInactiveTrace = tm.mmGetTracePredictedInactiveColumns(); predictedInactiveColumnsMetric = tm.mmGetMetricFromTrace(predictedInactiveTrace); double predictedInactiveColumnsMean2 = predictedInactiveColumnsMetric.mean; assertTrue(predictedInactiveColumnsMean1 > 0); assertTrue(predictedInactiveColumnsMean1 > predictedInactiveColumnsMean2); }