Skip to content

Commit 76461c3

Browse files
committed
Changed temporal input into Classifiers to activeCells; changed tests to accommodate; changed ArrayUtils.isSparse to short circuit when false for speed up; Added SDR class for sdr operations
1 parent 59d4264 commit 76461c3

File tree

13 files changed

+886
-685
lines changed

13 files changed

+886
-685
lines changed

src/main/java/org/numenta/nupic/Parameters.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ public void apply(Object cn) {
474474
Set<KEY> presentKeys = paramMap.keySet();
475475
synchronized (paramMap) {
476476
for (KEY key : presentKeys) {
477+
if(key == KEY.RANDOM) continue;
477478
beanUtil.setSimpleProperty(cn, key.fieldName, getParameterByKey(key));
478479
}
479480
}

src/main/java/org/numenta/nupic/algorithms/TemporalMemory.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,14 @@ public void learnOnSegments(Connections c, Set<DistalDendrite> prevActiveSegment
311311
public void computePredictiveCells(Connections c, ComputeCycle cycle, Set<Cell> activeCells) {
312312
TObjectIntMap<DistalDendrite> numActiveConnectedSynapsesForSegment = new TObjectIntHashMap<>();
313313
TObjectIntMap<DistalDendrite> numActiveSynapsesForSegment = new TObjectIntHashMap<>();
314+
double connectedPermanence = c.getConnectedPermanence();
314315

315316
for(Cell cell : activeCells) {
316317
for(Synapse syn : c.getReceptorSynapses(cell)) {
317318
DistalDendrite segment = (DistalDendrite)syn.getSegment();
318319
double permanence = syn.getPermanence();
319320

320-
if(permanence >= c.getConnectedPermanence()) {
321+
if(permanence >= connectedPermanence) {
321322
numActiveConnectedSynapsesForSegment.adjustOrPutValue(segment, 1, 1);
322323

323324
if(numActiveConnectedSynapsesForSegment.get(segment) >= c.getActivationThreshold()) {
@@ -454,22 +455,6 @@ public Cell getLeastUsedCell(Connections c, List<Cell> columnCells) {
454455
return l.get(randomIdx);
455456
}
456457

457-
/**
458-
* Used locally to return results of column Burst
459-
*/
460-
class BurstResult {
461-
Set<Cell> activeCells;
462-
Set<Cell> winnerCells;
463-
Set<DistalDendrite> learningSegments;
464-
465-
public BurstResult(Set<Cell> activeCells, Set<Cell> winnerCells, Set<DistalDendrite> learningSegments) {
466-
super();
467-
this.activeCells = activeCells;
468-
this.winnerCells = winnerCells;
469-
this.learningSegments = learningSegments;
470-
}
471-
}
472-
473458
/**
474459
* Used locally to return best cell/segment pair
475460
*/

src/main/java/org/numenta/nupic/network/Inference.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@
2222
package org.numenta.nupic.network;
2323

2424
import java.util.Map;
25+
import java.util.Set;
2526

27+
import org.numenta.nupic.ComputeCycle;
2628
import org.numenta.nupic.algorithms.CLAClassifier;
2729
import org.numenta.nupic.algorithms.ClassifierResult;
2830
import org.numenta.nupic.algorithms.SpatialPooler;
31+
import org.numenta.nupic.algorithms.TemporalMemory;
2932
import org.numenta.nupic.encoders.Encoder;
33+
import org.numenta.nupic.model.Cell;
3034
import org.numenta.nupic.util.NamedTuple;
3135

3236
import rx.functions.Func1;
@@ -48,6 +52,11 @@ public interface Inference {
4852
* @return
4953
*/
5054
public int getRecordNum();
55+
/**
56+
* Returns the {@link ComputeCycle}
57+
* @return
58+
*/
59+
public ComputeCycle getComputeCycle();
5160
/**
5261
* Returns a custom Object during sequence processing where one or more
5362
* {@link Func1}(s) were added to a {@link Layer} in between algorithmic
@@ -108,20 +117,25 @@ public interface Inference {
108117
* Returns the column activation from a {@link SpatialPooler}
109118
* @return
110119
*/
111-
public int[] getActiveColumns();
120+
public int[] getFeedForwardActiveColumns();
112121
/**
113122
* Returns the column activations in sparse form
114123
* @return
115124
*/
116-
public int[] getSparseActives();
125+
public int[] getFeedForwardSparseActives();
126+
/**
127+
* Returns the column activation from a {@link TemporalMemory}
128+
* @return
129+
*/
130+
public Set<Cell> getActiveCells();
117131
/**
118132
* Returns the predicted output from the last inference cycle.
119133
* @return
120134
*/
121-
public int[] getPreviousPrediction();
135+
public Set<Cell> getPreviousPredictiveCells();
122136
/**
123137
* Returns the currently predicted columns.
124138
* @return
125139
*/
126-
public int[] getPredictedColumns();
140+
public Set<Cell> getPredictiveCells();
127141
}

0 commit comments

Comments
 (0)