Skip to content

Commit 7d1c3b9

Browse files
author
cogmission
committed
Added new Generator Implementation for new TemporalMemory, and the test for it.
1 parent 4818a37 commit 7d1c3b9

36 files changed

+1343
-810
lines changed

Diff for: [ htm.java Unit Test ] TemporalMemoryTest.launch renamed to [ htm.java Unit Test ] OldTemporalMemoryTest.launch

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
22
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
33
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
4-
<listEntry value="/htm.java/src/test/java/org/numenta/nupic/algorithms/TemporalMemoryTest.java"/>
4+
<listEntry value="/htm.java/src/test/java/org/numenta/nupic/algorithms/OldTemporalMemoryTest.java"/>
55
</listAttribute>
66
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
77
<listEntry value="1"/>
@@ -25,7 +25,7 @@
2525
</listAttribute>
2626
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
2727
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
28-
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.numenta.nupic.algorithms.TemporalMemoryTest"/>
28+
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.numenta.nupic.algorithms.OldTemporalMemoryTest"/>
2929
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="htm.java"/>
3030
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
3131
</launchConfiguration>

Diff for: src/jmh/java/org/numenta/nupic/benchmarks/AbstractAlgorithmBenchmark.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.numenta.nupic.Parameters;
2727
import org.numenta.nupic.Parameters.KEY;
2828
import org.numenta.nupic.algorithms.SpatialPooler;
29-
import org.numenta.nupic.algorithms.TemporalMemory;
29+
import org.numenta.nupic.algorithms.OldTemporalMemory;
3030
import org.numenta.nupic.encoders.ScalarEncoder;
3131
import org.openjdk.jmh.annotations.Scope;
3232
import org.openjdk.jmh.annotations.Setup;
@@ -38,7 +38,7 @@ public abstract class AbstractAlgorithmBenchmark {
3838
protected int[] SDR;
3939
protected ScalarEncoder encoder;
4040
protected SpatialPooler pooler;
41-
protected TemporalMemory temporalMemory;
41+
protected OldTemporalMemory temporalMemory;
4242
protected Connections memory;
4343

4444
@Setup
@@ -65,7 +65,7 @@ public void init() {
6565
pooler = new SpatialPooler();
6666
pooler.init(memory);
6767

68-
temporalMemory = new TemporalMemory();
68+
temporalMemory = new OldTemporalMemory();
6969
temporalMemory.init(memory);
7070
}
7171

Diff for: src/main/java/org/numenta/nupic/ComputeCycle.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
import java.util.Map;
2727
import java.util.Set;
2828

29-
import org.numenta.nupic.algorithms.TemporalMemory;
29+
import org.numenta.nupic.algorithms.OldTemporalMemory;
3030
import org.numenta.nupic.model.Cell;
3131
import org.numenta.nupic.model.Column;
3232
import org.numenta.nupic.model.DistalDendrite;
3333

3434
/**
3535
* Contains a snapshot of the state attained during one computational
36-
* call to the {@link TemporalMemory}. The {@code TemporalMemory} uses
36+
* call to the {@link OldTemporalMemory}. The {@code TemporalMemory} uses
3737
* data from previous compute cycles to derive new data for the current cycle
3838
* through a comparison between states of those different cycles, therefore
3939
* this state container is necessary.
@@ -62,7 +62,7 @@ public ComputeCycle() {}
6262
/**
6363
* Constructs a new {@code ComputeCycle} initialized with
6464
* the connections relevant to the current calling {@link Thread} for
65-
* the specified {@link TemporalMemory}
65+
* the specified {@link OldTemporalMemory}
6666
*
6767
* @param c the current connections state of the TemporalMemory
6868
*/
@@ -136,7 +136,7 @@ public Set<Cell> predictedInactiveCells() {
136136

137137
/**
138138
* Returns the Set of matching {@link DistalDendrite}s from
139-
* {@link TemporalMemory#computePredictiveCells(Connections, ComputeCycle, Map)}
139+
* {@link OldTemporalMemory#computePredictiveCells(Connections, ComputeCycle, Map)}
140140
* @return
141141
*/
142142
public Set<DistalDendrite> matchingSegments() {
@@ -145,7 +145,7 @@ public Set<DistalDendrite> matchingSegments() {
145145

146146
/**
147147
* Returns the Set of matching {@link Cell}s from
148-
* {@link TemporalMemory#computePredictiveCells(Connections, ComputeCycle, Map)}
148+
* {@link OldTemporalMemory#computePredictiveCells(Connections, ComputeCycle, Map)}
149149
* @return
150150
*/
151151
public Set<Cell> matchingCells() {

Diff for: src/main/java/org/numenta/nupic/Connections.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
import org.numenta.nupic.algorithms.PASpatialPooler;
3636
import org.numenta.nupic.algorithms.SpatialPooler;
37-
import org.numenta.nupic.algorithms.TemporalMemory;
37+
import org.numenta.nupic.algorithms.OldTemporalMemory;
3838
import org.numenta.nupic.model.Cell;
3939
import org.numenta.nupic.model.Column;
4040
import org.numenta.nupic.model.DistalDendrite;
@@ -50,7 +50,7 @@
5050

5151
/**
5252
* Contains the definition of the interconnected structural state of the {@link SpatialPooler} and
53-
* {@link TemporalMemory} as well as the state of all support structures
53+
* {@link OldTemporalMemory} as well as the state of all support structures
5454
* (i.e. Cells, Columns, Segments, Synapses etc.).
5555
*
5656
* In the separation of data from logic, this class represents the data/state.

Diff for: src/main/java/org/numenta/nupic/Parameters.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import java.util.Set;
3434

3535
import org.numenta.nupic.algorithms.SpatialPooler;
36-
import org.numenta.nupic.algorithms.TemporalMemory;
36+
import org.numenta.nupic.algorithms.OldTemporalMemory;
3737
import org.numenta.nupic.model.Cell;
3838
import org.numenta.nupic.model.Column;
3939
import org.numenta.nupic.model.DistalDendrite;
@@ -47,13 +47,13 @@
4747
import com.cedarsoftware.util.DeepEquals;
4848

4949
/**
50-
* Specifies parameters to be used as a configuration for a given {@link TemporalMemory}
50+
* Specifies parameters to be used as a configuration for a given {@link OldTemporalMemory}
5151
* or {@link SpatialPooler}
5252
*
5353
* @author David Ray
5454
* @author Kirill Solovyev
5555
* @see SpatialPooler
56-
* @see TemporalMemory
56+
* @see OldTemporalMemory
5757
* @see Connections
5858
* @see ComputeCycle
5959
*/
@@ -140,7 +140,7 @@ public class Parameters implements Persistable {
140140
}
141141

142142
/**
143-
* Constant values representing configuration parameters for the {@link TemporalMemory}
143+
* Constant values representing configuration parameters for the {@link OldTemporalMemory}
144144
*/
145145
public static enum KEY {
146146
/////////// Universal Parameters ///////////

Diff for: src/main/java/org/numenta/nupic/algorithms/TemporalMemory.java renamed to src/main/java/org/numenta/nupic/algorithms/OldTemporalMemory.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@
2727
* @author Chetan Surpur
2828
* @author David Ray
2929
*/
30-
public class TemporalMemory implements ComputeDecorator, Serializable {
30+
public class OldTemporalMemory implements ComputeDecorator, Serializable {
3131
private static final long serialVersionUID = 1L;
3232

3333
/**
3434
* Constructs a new {@code TemporalMemory}
3535
*/
36-
public TemporalMemory() {}
36+
public OldTemporalMemory() {}
3737

3838
/**
3939
* Uses the specified {@link Connections} object to Build the structural
4040
* anatomy needed by this {@code TemporalMemory} to implement its algorithms.
4141
*
4242
* The connections object holds the {@link Column} and {@link Cell} infrastructure,
43-
* and is used by both the {@link SpatialPooler} and {@link TemporalMemory}. Either of
43+
* and is used by both the {@link SpatialPooler} and {@link OldTemporalMemory}. Either of
4444
* these can be used separately, and therefore this Connections object may have its
4545
* Columns and Cells initialized by either the init method of the SpatialPooler or the
4646
* init method of the TemporalMemory. We check for this so that complete initialization

Diff for: src/main/java/org/numenta/nupic/model/Column.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
import org.numenta.nupic.Connections;
3333
import org.numenta.nupic.algorithms.SpatialPooler;
34-
import org.numenta.nupic.algorithms.TemporalMemory;
34+
import org.numenta.nupic.algorithms.OldTemporalMemory;
3535

3636
/**
3737
* Abstraction of both an input bit and a columnal collection of
@@ -109,7 +109,7 @@ public int getIndex() {
109109

110110
/**
111111
* Returns the configured number of cells per column for
112-
* all {@code Column} objects within the current {@link TemporalMemory}
112+
* all {@code Column} objects within the current {@link OldTemporalMemory}
113113
* @return
114114
*/
115115
public int getNumCellsPerColumn() {

Diff for: src/main/java/org/numenta/nupic/monitor/MonitoredTemporalMemory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public MonitoredTemporalMemory(ComputeDecorator decorator, Connections cnx) {
7373

7474
/**
7575
* Returns the original class which is being tested. In this
76-
* case it is the {@link TemporalMemory}
76+
* case it is the {@link OldTemporalMemory}
7777
*/
7878
@SuppressWarnings("unchecked")
7979
@Override

Diff for: src/main/java/org/numenta/nupic/monitor/mixin/MonitorMixinBase.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
* <li>Create MonitorMixinBase extension mixin type (interface) (this does most of the mixin work) see {@link TemporalMemoryMonitorMixin}</li>
4848
* <li>Create Extension of both {@link MonitorMixinBase} and interface (see {@link MonitoredTemporalMemory})</li>
4949
* <li>Create constructor in extension class which takes above interface (A) which is the target class which must implement (A)</li>
50-
* <li>Make the Original class (see {@link TemporalMemory}) to be tested, implement the Decorator interface (A)</li>
50+
* <li>Make the Original class (see {@link OldTemporalMemory}) to be tested, implement the Decorator interface (A)</li>
5151
* <li>Use the "joining" extension class as you would the original class</li>
5252
* </OL>
5353
*

Diff for: src/main/java/org/numenta/nupic/monitor/mixin/TemporalMemoryMonitorMixin.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
import org.numenta.nupic.ComputeCycle;
3535
import org.numenta.nupic.Connections;
36-
import org.numenta.nupic.algorithms.TemporalMemory;
36+
import org.numenta.nupic.algorithms.OldTemporalMemory;
3737
import org.numenta.nupic.model.Cell;
3838
import org.numenta.nupic.model.Column;
3939
import org.numenta.nupic.model.DistalDendrite;
@@ -51,7 +51,7 @@
5151
* and create {@link Metric}s from them for analysis and pretty-printing
5252
*
5353
* This interface contains "defender" methods or Traits that are used to collect
54-
* result data for the {@link TemporalMemory}.
54+
* result data for the {@link OldTemporalMemory}.
5555
*
5656
* @author cogmission
5757
*
@@ -487,7 +487,7 @@ default ComputeCycle compute(Connections cnx, int[] activeColumns, String sequen
487487
}
488488

489489
/**
490-
* Called to delegate a {@link TemporalMemory#reset(Connections)} call and
490+
* Called to delegate a {@link OldTemporalMemory#reset(Connections)} call and
491491
* then set a flag locally which controls remaking of test {@link Trace}s.
492492
*
493493
* @param c
@@ -500,7 +500,7 @@ default void resetSequences(Connections c) {
500500

501501
/**
502502
* Returns a list of {@link Trace} objects containing data sets used
503-
* to analyze the behavior and state of the {@link TemporalMemory} This
503+
* to analyze the behavior and state of the {@link OldTemporalMemory} This
504504
* method is called from all of the "mmXXX" methods to make sure that
505505
* the data represents the most current execution cycle of the TM.
506506
*
@@ -535,7 +535,7 @@ default <T extends Trace<?>> List<T> mmGetDefaultTraces(int verbosity) {
535535

536536
/**
537537
* Returns a list of {@link Metric} objects containing statistics used
538-
* to analyze the behavior and state of the {@link TemporalMemory} This
538+
* to analyze the behavior and state of the {@link OldTemporalMemory} This
539539
* method is called from all of the "mmXXX" methods to make sure that
540540
* the data represents the most current execution cycle of the TM.
541541
*

Diff for: src/main/java/org/numenta/nupic/network/Inference.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.numenta.nupic.algorithms.CLAClassifier;
3030
import org.numenta.nupic.algorithms.Classification;
3131
import org.numenta.nupic.algorithms.SpatialPooler;
32-
import org.numenta.nupic.algorithms.TemporalMemory;
32+
import org.numenta.nupic.algorithms.OldTemporalMemory;
3333
import org.numenta.nupic.encoders.Encoder;
3434
import org.numenta.nupic.model.Cell;
3535
import org.numenta.nupic.util.NamedTuple;
@@ -125,7 +125,7 @@ public interface Inference extends Persistable {
125125
*/
126126
public int[] getFeedForwardSparseActives();
127127
/**
128-
* Returns the column activation from a {@link TemporalMemory}
128+
* Returns the column activation from a {@link OldTemporalMemory}
129129
* @return
130130
*/
131131
public Set<Cell> getActiveCells();

Diff for: src/main/java/org/numenta/nupic/network/Layer.java

+17-17
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import org.numenta.nupic.algorithms.CLAClassifier;
4545
import org.numenta.nupic.algorithms.Classification;
4646
import org.numenta.nupic.algorithms.SpatialPooler;
47-
import org.numenta.nupic.algorithms.TemporalMemory;
47+
import org.numenta.nupic.algorithms.OldTemporalMemory;
4848
import org.numenta.nupic.encoders.DateEncoder;
4949
import org.numenta.nupic.encoders.Encoder;
5050
import org.numenta.nupic.encoders.EncoderTuple;
@@ -186,7 +186,7 @@ public class Layer<T> implements Persistable {
186186
protected HTMSensor<?> sensor;
187187
protected MultiEncoder encoder;
188188
protected SpatialPooler spatialPooler;
189-
protected TemporalMemory temporalMemory;
189+
protected OldTemporalMemory temporalMemory;
190190
private Boolean autoCreateClassifiers;
191191
private Anomaly anomalyComputer;
192192

@@ -203,11 +203,11 @@ public class Layer<T> implements Persistable {
203203
protected int[] feedForwardActiveColumns;
204204
/** Active column indexes from the {@link SpatialPooler} at time "t" */
205205
private int[] feedForwardSparseActives;
206-
/** Predictive {@link Cell}s in the {@link TemporalMemory} at time "t - 1" */
206+
/** Predictive {@link Cell}s in the {@link OldTemporalMemory} at time "t - 1" */
207207
private Set<Cell> previousPredictiveCells;
208-
/** Predictive {@link Cell}s in the {@link TemporalMemory} at time "t" */
208+
/** Predictive {@link Cell}s in the {@link OldTemporalMemory} at time "t" */
209209
private Set<Cell> predictiveCells;
210-
/** Active {@link Cell}s in the {@link TemporalMemory} at time "t" */
210+
/** Active {@link Cell}s in the {@link OldTemporalMemory} at time "t" */
211211
private Set<Cell> activeCells;
212212

213213
/** Used to track and document the # of records processed */
@@ -363,12 +363,12 @@ public void setNetwork(Network network) {
363363
* @param e (optional) The Network API only uses a {@link MultiEncoder} at
364364
* the top level because of its ability to delegate to child encoders.
365365
* @param sp (optional) {@link SpatialPooler}
366-
* @param tm (optional) {@link TemporalMemory}
366+
* @param tm (optional) {@link OldTemporalMemory}
367367
* @param autoCreateClassifiers (optional) Indicates that the {@link Parameters} object
368368
* contains the configurations necessary to create the required encoders.
369369
* @param a (optional) An {@link Anomaly} computer.
370370
*/
371-
public Layer(Parameters params, MultiEncoder e, SpatialPooler sp, TemporalMemory tm, Boolean autoCreateClassifiers, Anomaly a) {
371+
public Layer(Parameters params, MultiEncoder e, SpatialPooler sp, OldTemporalMemory tm, Boolean autoCreateClassifiers, Anomaly a) {
372372

373373
// Make sure we have a valid parameters object
374374
if(params == null) {
@@ -549,7 +549,7 @@ public Layer<T> close() {
549549

550550
/**
551551
* Called from {@link FunctionFactory#createSpatialFunc(SpatialPooler)} and from {@link #close()}
552-
* to calculate the size of the input vector given the output source either being a {@link TemporalMemory}
552+
* to calculate the size of the input vector given the output source either being a {@link OldTemporalMemory}
553553
* or a {@link SpatialPooler} - from this {@link Region} or a previous {@link Region}.
554554
*
555555
* @return the length of the input vector
@@ -590,7 +590,7 @@ int calculateInputWidth() {
590590

591591
/**
592592
* For internal use only. Returns a flag indicating whether this {@link Layer}
593-
* contains a {@link TemporalMemory}
593+
* contains a {@link OldTemporalMemory}
594594
* @return
595595
*/
596596
boolean hasTM() {
@@ -804,12 +804,12 @@ public Layer<T> add(SpatialPooler sp) {
804804
}
805805

806806
/**
807-
* Adds a {@link TemporalMemory} to this {@code Layer}
807+
* Adds a {@link OldTemporalMemory} to this {@code Layer}
808808
*
809809
* @param tm the added TemporalMemory
810810
* @return this Layer instance (in fluent-style)
811811
*/
812-
public Layer<T> add(TemporalMemory tm) {
812+
public Layer<T> add(OldTemporalMemory tm) {
813813
if(isClosed) {
814814
throw new IllegalStateException("Layer already \"closed\"");
815815
}
@@ -1194,7 +1194,7 @@ public int[] getFeedForwardActiveColumns() {
11941194
}
11951195

11961196
/**
1197-
* Returns the {@link Cell}s activated in the {@link TemporalMemory} at time
1197+
* Returns the {@link Cell}s activated in the {@link OldTemporalMemory} at time
11981198
* "t"
11991199
*
12001200
* @return
@@ -1263,7 +1263,7 @@ public Layer<T> resetRecordNum() {
12631263
}
12641264

12651265
/**
1266-
* Resets the {@link TemporalMemory} if it exists.
1266+
* Resets the {@link OldTemporalMemory} if it exists.
12671267
*/
12681268
public void reset() {
12691269
if(temporalMemory == null) {
@@ -1275,7 +1275,7 @@ public void reset() {
12751275

12761276
/**
12771277
* Returns a flag indicating whether this {@code Layer} contains a
1278-
* {@link TemporalMemory}.
1278+
* {@link OldTemporalMemory}.
12791279
*
12801280
* @return
12811281
*/
@@ -1784,7 +1784,7 @@ private Observable<ManualInput> fillInOrderedSequence(Observable<ManualInput> o)
17841784
} else {
17851785
o = o.map(factory.createSpatialFunc(spatialPooler));
17861786
}
1787-
} else if(node instanceof TemporalMemory) {
1787+
} else if(node instanceof OldTemporalMemory) {
17881788
o = o.map(factory.createTemporalFunc(temporalMemory));
17891789
}
17901790
}
@@ -1947,7 +1947,7 @@ protected int[] spatialInput(int[] input) {
19471947
}
19481948

19491949
/**
1950-
* Called internally to invoke the {@link TemporalMemory}
1950+
* Called internally to invoke the {@link OldTemporalMemory}
19511951
*
19521952
* @param input the current input vector
19531953
* @param mi the current input inference container
@@ -2293,7 +2293,7 @@ public ManualInput call(ManualInput t1) {
22932293
};
22942294
}
22952295

2296-
public Func1<ManualInput, ManualInput> createTemporalFunc(final TemporalMemory tm) {
2296+
public Func1<ManualInput, ManualInput> createTemporalFunc(final OldTemporalMemory tm) {
22972297
return new Func1<ManualInput, ManualInput>() {
22982298

22992299
@Override

0 commit comments

Comments
 (0)