Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync latest sp #486

Merged
merged 7 commits into from
Oct 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ test {
}

// UNCOMMENT TO SEE STANDARD_OUT & STANDARD_ERR DURING BUILD

/*
test {
testLogging.showStandardStreams = true
}
*/

dependencies {
compile group: 'joda-time', name: 'joda-time', version: '2.5'
Expand Down
78 changes: 73 additions & 5 deletions src/main/java/org/numenta/nupic/Connections.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.numenta.nupic.util.FlatMatrix;
import org.numenta.nupic.util.SparseMatrix;
import org.numenta.nupic.util.SparseObjectMatrix;
import org.numenta.nupic.util.Topology;
import org.numenta.nupic.util.Tuple;
import org.numenta.nupic.util.UniversalRandom;

Expand Down Expand Up @@ -92,6 +93,7 @@ public class Connections implements Persistable {
private double predictedSegmentDecrement = 0.0;
private int dutyCyclePeriod = 1000;
private double maxBoost = 10.0;
private boolean wrapAround = true;

private int numInputs = 1; //product of input dimensions
private int numColumns = 1; //product of column dimensions
Expand All @@ -111,7 +113,11 @@ public class Connections implements Persistable {

public double[] boostedOverlaps;
public int[] overlaps;


/** Manages input neighborhood transformations */
private Topology inputTopology;
/** Manages column neighborhood transformations */
private Topology columnTopology;
/** A matrix representing the shape of the input. */
protected SparseMatrix<?> inputMatrix;
/**
Expand Down Expand Up @@ -152,8 +158,8 @@ public class Connections implements Persistable {

private double[] overlapDutyCycles;
private double[] activeDutyCycles;
private double[] minOverlapDutyCycles;
private double[] minActiveDutyCycles;
private volatile double[] minOverlapDutyCycles;
private volatile double[] minActiveDutyCycles;
private double[] boostFactors;

/////////////////////////////////////// Temporal Memory Vars ///////////////////////////////////////////
Expand Down Expand Up @@ -379,6 +385,44 @@ public void setMemory(SparseObjectMatrix<Column> mem) {
public SparseObjectMatrix<Column> getMemory() {
return memory;
}

/**
* Returns the {@link Topology} overseeing input
* neighborhoods.
* @return
*/
public Topology getInputTopology() {
return inputTopology;
}

/**
* Sets the {@link Topology} overseeing input
* neighborhoods.
*
* @param topology the input Topology
*/
public void setInputTopology(Topology topology) {
this.inputTopology = topology;
}

/**
* Returns the {@link Topology} overseeing {@link Column}
* neighborhoods.
* @return
*/
public Topology getColumnTopology() {
return columnTopology;
}

/**
* Sets the {@link Topology} overseeing {@link Column}
* neighborhoods.
*
* @param topology the column Topology
*/
public void setColumnTopology(Topology topology) {
this.columnTopology = topology;
}

/**
* Returns the input column mapping
Expand Down Expand Up @@ -950,6 +994,25 @@ public double getMaxBoost() {
return maxBoost;
}

/**
* Specifies whether neighborhoods wider than the
* borders wrap around to the other side.
* @param b
*/
public void setWrapAround(boolean b) {
this.wrapAround = b;
}

/**
* Returns a flag indicating whether neighborhoods
* wider than the borders, wrap around to the other
* side.
* @return
*/
public boolean isWrapAround() {
return wrapAround;
}

/**
* Sets and Returns the boosted overlap score for each column
* @param boostedOverlaps
Expand Down Expand Up @@ -1051,6 +1114,10 @@ public double[] getOverlapDutyCycles() {
return overlapDutyCycles;
}

/**
* Sets the overlap duty cycles
* @param overlapDutyCycles
*/
public void setOverlapDutyCycles(double[] overlapDutyCycles) {
this.overlapDutyCycles = overlapDutyCycles;
}
Expand Down Expand Up @@ -2294,9 +2361,10 @@ public String getPrintString() {
pw.println("synPermConnected = " + getSynPermConnected());
pw.println("synPermBelowStimulusInc = " + getSynPermBelowStimulusInc());
pw.println("synPermTrimThreshold = " + getSynPermTrimThreshold());
pw.println("minPctOverlapDutyCycles = " + getMinPctOverlapDutyCycles());
pw.println("minPctActiveDutyCycles = " + getMinPctActiveDutyCycles());
pw.println("minPctOverlapDutyCycles = " + getMinPctOverlapDutyCycles());
pw.println("minPctActiveDutyCycles = " + getMinPctActiveDutyCycles());
pw.println("dutyCyclePeriod = " + getDutyCyclePeriod());
pw.println("wrapAround = " + isWrapAround());
pw.println("maxBoost = " + getMaxBoost());
pw.println("version = " + getVersion());

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/numenta/nupic/Parameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public class Parameters implements Persistable {
defaultSpatialParams.put(KEY.MIN_PCT_ACTIVE_DUTY_CYCLES, 0.001);
defaultSpatialParams.put(KEY.DUTY_CYCLE_PERIOD, 1000);
defaultSpatialParams.put(KEY.MAX_BOOST, 10.0);
defaultSpatialParams.put(KEY.WRAP_AROUND, true);
defaultSpatialParams.put(KEY.LEARN, true);
DEFAULTS_SPATIAL = Collections.unmodifiableMap(defaultSpatialParams);
defaultParams.putAll(DEFAULTS_SPATIAL);
Expand Down Expand Up @@ -245,7 +246,7 @@ public static enum KEY {
MIN_PCT_ACTIVE_DUTY_CYCLES("minPctActiveDutyCycles", Double.class),//TODO add range here?
DUTY_CYCLE_PERIOD("dutyCyclePeriod", Integer.class),//TODO add range here?
MAX_BOOST("maxBoost", Double.class), //TODO add range here?
//SP_VERBOSITY("spVerbosity", Integer.class, 0, 10),
WRAP_AROUND("wrapAround", Boolean.class),

///////////// SpatialPooler / Network Parameter(s) /////////////
/** Number of cycles to send through the SP before forwarding data to the rest of the network. */
Expand Down
Loading