Skip to content

Commit

Permalink
Merge pull request #313 from cogmission/0.6.3-SNAPSHOT
Browse files Browse the repository at this point in the history
0.6.3 snapshot
  • Loading branch information
cogmission committed Sep 17, 2015
2 parents 3b540f6 + 8ccb3d5 commit 13335c6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 56 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ apply plugin: 'eclipse'
apply plugin: 'signing'

group = 'org.numenta'
version = '0.6.2'
version = '0.6.3-SNAPSHOT'
archivesBaseName = 'htm.java'

sourceCompatibility = 1.8
targetCompatibility = 1.8

jar {
manifest {
attributes 'Implementation-Title': 'htm.java', 'Implementation-Version': '0.6.2'
attributes 'Implementation-Title': 'htm.java', 'Implementation-Version': '0.6.3-SNAPSHOT'
}
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.numenta</groupId>
<artifactId>htm.java</artifactId>
<version>0.6.2</version>
<version>0.6.3-SNAPSHOT</version>
<name>htm.java</name>
<description>The Java version of Numenta's HTM technology</description>

Expand Down
101 changes: 48 additions & 53 deletions src/test/java/org/numenta/nupic/network/LayerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ public void testHalt() {
isHalted = true;
}
@Override public void onError(Throwable e) { e.printStackTrace(); }
@Override public void onNext(Inference output) {
System.out.println("output = " + Arrays.toString(output.getSDR()));
}
@Override public void onNext(Inference output) {}
});

try {
Expand All @@ -266,9 +264,9 @@ public void testHalt() {
@Test
public void testReset() {
Sensor<File> sensor = Sensor.create(
FileSensor::create,
SensorParams.create(
Keys::path, "", ResourceLocator.path("rec-center-hourly-4reset.csv")));
FileSensor::create,
SensorParams.create(
Keys::path, "", ResourceLocator.path("rec-center-hourly-4reset.csv")));

Parameters p = NetworkTestHarness.getParameters().copy();
p = p.union(NetworkTestHarness.getHotGymTestEncoderParams());
Expand Down Expand Up @@ -306,9 +304,9 @@ public void testReset() {
@Test
public void testSequenceChangeReset() {
Sensor<File> sensor = Sensor.create(
FileSensor::create,
SensorParams.create(
Keys::path, "", ResourceLocator.path("rec-center-hourly-4seqReset.csv")));
FileSensor::create,
SensorParams.create(
Keys::path, "", ResourceLocator.path("rec-center-hourly-4seqReset.csv")));

Parameters p = NetworkTestHarness.getParameters().copy();
p = p.union(NetworkTestHarness.getHotGymTestEncoderParams());
Expand Down Expand Up @@ -345,15 +343,15 @@ public void testSequenceChangeReset() {
@Test
public void testLayerWithObservableInput() {
Publisher manual = Publisher.builder()
.addHeader("timestamp,consumption")
.addHeader("datetime,float")
.addHeader("B")
.build();
.addHeader("timestamp,consumption")
.addHeader("datetime,float")
.addHeader("B")
.build();

Sensor<ObservableSensor<String[]>> sensor = Sensor.create(
ObservableSensor::create,
SensorParams.create(
Keys::obs, new Object[] {"name", manual}));
ObservableSensor::create,
SensorParams.create(
Keys::obs, new Object[] {"name", manual}));

Parameters p = NetworkTestHarness.getParameters().copy();
p = p.union(NetworkTestHarness.getHotGymTestEncoderParams());
Expand Down Expand Up @@ -387,9 +385,9 @@ public void testLayerWithObservableInput() {

try {
String[] entries = {
"7/2/10 0:00,21.2",
"7/2/10 1:00,34.0",
"7/2/10 2:00,40.4",
"7/2/10 0:00,21.2",
"7/2/10 1:00,34.0",
"7/2/10 2:00,40.4",
};

// Send inputs through the observable
Expand All @@ -407,15 +405,15 @@ public void testLayerWithObservableInput() {
@Test
public void testLayerWithObservableInputIntegerArray() {
Publisher manual = Publisher.builder()
.addHeader("sdr_in")
.addHeader("darr")
.addHeader("B")
.build();
.addHeader("sdr_in")
.addHeader("darr")
.addHeader("B")
.build();

Sensor<ObservableSensor<String[]>> sensor = Sensor.create(
ObservableSensor::create,
SensorParams.create(
Keys::obs, new Object[] {"name", manual}));
ObservableSensor::create,
SensorParams.create(
Keys::obs, new Object[] {"name", manual}));

Parameters p = Parameters.getAllDefaultParameters();
p = p.union(getArrayTestParams());
Expand Down Expand Up @@ -498,10 +496,10 @@ public void testLayerWithGenericObservable() {
};

Network n = Network.create("Generic Test", p)
.add(Network.createRegion("R1")
.add(Network.createLayer("L1", p)
.add(addedFunc)
.add(new SpatialPooler())));
.add(Network.createRegion("R1")
.add(Network.createLayer("L1", p)
.add(addedFunc)
.add(new SpatialPooler())));

@SuppressWarnings("unchecked")
Layer<int[]> l = (Layer<int[]>)n.lookup("R1").lookup("L1");
Expand Down Expand Up @@ -647,7 +645,6 @@ public void testBasicSetupEncoder_AUTO_MODE() {
@Override public void onNext(Inference output) {
// System.out.println(" seq = " + seq + ", recNum = " + output.getRecordNum() + ", expected = " + Arrays.toString(expected[seq]));
// System.out.println(" seq = " + seq + ", recNum = " + output.getRecordNum() + ", output = " + Arrays.toString(output.getSDR()));
if(seq == output.getRecordNum())
assertTrue(Arrays.equals(expected[seq], output.getSDR()));
seq++;
}
Expand All @@ -660,7 +657,6 @@ public void testBasicSetupEncoder_AUTO_MODE() {
@Override public void onNext(Inference output) {
// System.out.println(" seq = " + seq2 + ", recNum = " + output.getRecordNum() + ", expected = " + Arrays.toString(expected[seq2]));
// System.out.println(" seq = " + seq2 + ", recNum = " + output.getRecordNum() + ", output = " + Arrays.toString(output.getSDR()));
if(seq2 == output.getRecordNum())
assertTrue(Arrays.equals(expected[seq2], output.getSDR()));
seq2++;
}
Expand Down Expand Up @@ -725,9 +721,9 @@ public void onNext(Inference spatialPoolerOutput) {
@Test
public void testBasicSetup_SpatialPooler_AUTO_MODE() {
Sensor<File> sensor = Sensor.create(
FileSensor::create,
SensorParams.create(
Keys::path, "", ResourceLocator.path("days-of-week.csv")));
FileSensor::create,
SensorParams.create(
Keys::path, "", ResourceLocator.path("days-of-week.csv")));

Parameters p = NetworkTestHarness.getParameters().copy();
p = p.union(NetworkTestHarness.getDayDemoTestEncoderParams());
Expand Down Expand Up @@ -1117,8 +1113,8 @@ public void testAnomalySetup() {
params.put(KEY_USE_MOVING_AVG, true);
Anomaly anomalyComputer = Anomaly.create(params);

final Layer<Map<String, Object>> l = new Layer<>(p, me, new SpatialPooler(), new TemporalMemory(),
Boolean.TRUE, anomalyComputer);
final Layer<Map<String, Object>> l = new Layer<>(
p, me, new SpatialPooler(), new TemporalMemory(), Boolean.TRUE, anomalyComputer);

l.subscribe(new Observer<Inference>() {
@Override public void onCompleted() {}
Expand Down Expand Up @@ -1312,14 +1308,14 @@ public void testFullLayerFluentAssembly() {
Anomaly anomalyComputer = Anomaly.create(params);

Layer<?> l = Network.createLayer("TestLayer", p)
.alterParameter(KEY.AUTO_CLASSIFY, true)
.add(anomalyComputer)
.add(new TemporalMemory())
.add(new SpatialPooler())
.add(Sensor.create(
FileSensor::create,
SensorParams.create(
Keys::path, "", ResourceLocator.path("rec-center-hourly-small.csv"))));
.alterParameter(KEY.AUTO_CLASSIFY, true)
.add(anomalyComputer)
.add(new TemporalMemory())
.add(new SpatialPooler())
.add(Sensor.create(
FileSensor::create,
SensorParams.create(
Keys::path, "", ResourceLocator.path("rec-center-hourly-small.csv"))));

l.getConnections().printParameters();

Expand All @@ -1330,10 +1326,9 @@ public void testFullLayerFluentAssembly() {
public void onNext(Inference i) {
if(flowReceived) return; // No need to set this value multiple times

System.out.println("classifier size = " + i.getClassifiers().size());
flowReceived = i.getClassifiers().size() == 4 &&
i.getClassifiers().get("timestamp") != null &&
i.getClassifiers().get("consumption") != null;
i.getClassifiers().get("timestamp") != null &&
i.getClassifiers().get("consumption") != null;
}
});

Expand All @@ -1349,11 +1344,11 @@ public void onNext(Inference i) {

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");
null,
884, // n
0, // w
0, 0, 0, 0, null, null, null,
"sdr_in", "darr", "SDRPassThroughEncoder");
Parameters p = Parameters.empty();
p.setParameterByKey(KEY.FIELD_ENCODING_MAP, fieldEncodings);
return p;
Expand Down

0 comments on commit 13335c6

Please sign in to comment.