本文整理汇总了Java中org.numenta.nupic.Parameters.KEY类的典型用法代码示例。如果您正苦于以下问题:Java KEY类的具体用法?Java KEY怎么用?Java KEY使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KEY类属于org.numenta.nupic.Parameters包,在下文中一共展示了KEY类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHotGymFieldEncodingMap
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
/**
* Returns the Hot Gym encoder setup.
* @return
*/
public static Map<String, Map<String, Object>> getHotGymFieldEncodingMap() {
Map<String, Map<String, Object>> fieldEncodings = setupMap(
null,
0, // n
0, // w
0, 0, 0, 0, null, null, null,
"timestamp", "datetime", "DateEncoder");
fieldEncodings = setupMap(
fieldEncodings,
25,
3,
0, 0, 0, 0.1, null, null, null,
"consumption", "float", "RandomDistributedScalarEncoder");
fieldEncodings.get("timestamp").put(KEY.DATEFIELD_DOFW.getFieldName(), new Tuple(1, 1.0)); // Day of week
fieldEncodings.get("timestamp").put(KEY.DATEFIELD_TOFD.getFieldName(), new Tuple(5, 4.0)); // Time of day
fieldEncodings.get("timestamp").put(KEY.DATEFIELD_PATTERN.getFieldName(), "MM/dd/YY HH:mm");
return fieldEncodings;
}
示例2: getNetworkDemoFieldEncodingMap
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
/**
* Returns the Hot Gym encoder setup.
* @return
*/
public static Map<String, Map<String, Object>> getNetworkDemoFieldEncodingMap() {
Map<String, Map<String, Object>> fieldEncodings = setupMap(
null,
0, // n
0, // w
0, 0, 0, 0, null, null, null,
"timestamp", "datetime", "DateEncoder");
fieldEncodings = setupMap(
fieldEncodings,
50,
21,
0, 100, 0, 0.1, null, Boolean.TRUE, null,
"consumption", "float", "ScalarEncoder");
fieldEncodings.get("timestamp").put(KEY.DATEFIELD_TOFD.getFieldName(), new Tuple(21,9.5)); // Time of day
fieldEncodings.get("timestamp").put(KEY.DATEFIELD_PATTERN.getFieldName(), "MM/dd/YY HH:mm");
return fieldEncodings;
}
示例3: createBasicNetwork
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
/**
* Creates a basic {@link Network} with 1 {@link Region} and 1 {@link Layer}. However
* this basic network contains all algorithmic components.
*
* @return a basic Network
*/
Network createBasicNetwork() {
Parameters p = NetworkDemoHarness.getParameters();
p = p.union(NetworkDemoHarness.getNetworkDemoTestEncoderParams());
// This is how easy it is to create a full running Network!
return Network.create("Network API Demo", p)
.add(Network.createRegion("Region 1")
.add(Network.createLayer("Layer 2/3", p)
.alterParameter(KEY.AUTO_CLASSIFY, Boolean.TRUE)
.add(Anomaly.create())
.add(new TemporalMemory())
.add(new SpatialPooler())
.add(Sensor.create(FileSensor::create, SensorParams.create(
Keys::path, "", ResourceLocator.path("rec-center-hourly.csv"))))));
}
示例4: createMultiLayerNetwork
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
/**
* Creates a {@link Network} containing one {@link Region} with multiple
* {@link Layer}s. This demonstrates the method by which multiple layers
* are added and connected; and the flexibility of the fluent style api.
*
* @return a multi-layer Network
*/
Network createMultiLayerNetwork() {
Parameters p = NetworkDemoHarness.getParameters();
p = p.union(NetworkDemoHarness.getNetworkDemoTestEncoderParams());
return Network.create("Network API Demo", p)
.add(Network.createRegion("Region 1")
.add(Network.createLayer("Layer 2/3", p)
.alterParameter(KEY.AUTO_CLASSIFY, Boolean.TRUE)
.add(Anomaly.create())
.add(new TemporalMemory()))
.add(Network.createLayer("Layer 4", p)
.add(new SpatialPooler()))
.add(Network.createLayer("Layer 5", p)
.add(Sensor.create(FileSensor::create, SensorParams.create(
Keys::path, "", ResourceLocator.path("rec-center-hourly.csv")))))
.connect("Layer 2/3", "Layer 4")
.connect("Layer 4", "Layer 5"));
}
示例5: testLeastUsedCell
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
@Test
public void testLeastUsedCell() {
TemporalMemory tm = new TemporalMemory();
Connections cn = new Connections();
Parameters p = getDefaultParameters(null, KEY.COLUMN_DIMENSIONS, new int[] { 2 });
p = getDefaultParameters(p, KEY.CELLS_PER_COLUMN, 2);
p.apply(cn);
TemporalMemory.init(cn);
DistalDendrite dd = cn.createSegment(cn.getCell(0));
cn.createSynapse(dd, cn.getCell(3), 0.3);
for(int i = 0;i < 100;i++) {
assertEquals(1, tm.leastUsedCell(cn, cn.getColumn(0).getCells(), cn.getRandom()).getIndex());
}
}
示例6: setupParameters
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
public void setupParameters() {
parameters = Parameters.getAllDefaultParameters();
parameters.set(KEY.INPUT_DIMENSIONS, new int[] { 5 });//5
parameters.set(KEY.COLUMN_DIMENSIONS, new int[] { 5 });//5
parameters.set(KEY.POTENTIAL_RADIUS, 3);//3
parameters.set(KEY.POTENTIAL_PCT, 0.5);//0.5
parameters.set(KEY.GLOBAL_INHIBITION, false);
parameters.set(KEY.LOCAL_AREA_DENSITY, -1.0);
parameters.set(KEY.NUM_ACTIVE_COLUMNS_PER_INH_AREA, 3.0);
parameters.set(KEY.STIMULUS_THRESHOLD, 1.0);
parameters.set(KEY.SYN_PERM_INACTIVE_DEC, 0.01);
parameters.set(KEY.SYN_PERM_ACTIVE_INC, 0.1);
parameters.set(KEY.SYN_PERM_TRIM_THRESHOLD, 0.05);
parameters.set(KEY.SYN_PERM_CONNECTED, 0.1);
parameters.set(KEY.MIN_PCT_OVERLAP_DUTY_CYCLES, 0.1);
parameters.set(KEY.MIN_PCT_ACTIVE_DUTY_CYCLES, 0.1);
parameters.set(KEY.DUTY_CYCLE_PERIOD, 10);
parameters.set(KEY.MAX_BOOST, 10.0);
parameters.set(KEY.SEED, 42);
}
示例7: getHotGymFieldEncodingMap_varyDateFieldTupleValue
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
/**
* Returns the Hot Gym encoder setup.
* @return
*/
public static Map<String, Map<String, Object>> getHotGymFieldEncodingMap_varyDateFieldTupleValue() {
Map<String, Map<String, Object>> fieldEncodings = setupMap(
null,
0, // n
0, // w
0, 0, 0, 0, null, null, null,
"timestamp", "datetime", "DateEncoder");
fieldEncodings = setupMap(
fieldEncodings,
25,
3,
0, 0, 0, 0.1, null, null, null,
"consumption", "float", "RandomDistributedScalarEncoder");
fieldEncodings.get("timestamp").put(KEY.DATEFIELD_DOFW.getFieldName(), new Tuple(1, 2.0)); // Day of week
fieldEncodings.get("timestamp").put(KEY.DATEFIELD_TOFD.getFieldName(), new Tuple(5, 4.0)); // Time of day
fieldEncodings.get("timestamp").put(KEY.DATEFIELD_PATTERN.getFieldName(), "MM/dd/YY HH:mm");
return fieldEncodings;
}
示例8: createTMParams
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
/**
* Creates {@link Parameters} for tests
*/
protected Parameters createTMParams(Parameters overrides) {
parameters = Parameters.getAllDefaultParameters();
parameters.set(KEY.COLUMN_DIMENSIONS, new int[] { 100 });
parameters.set(KEY.CELLS_PER_COLUMN, 1);
parameters.set(KEY.INITIAL_PERMANENCE, 0.8);
parameters.set(KEY.CONNECTED_PERMANENCE, 0.7);
parameters.set(KEY.MIN_THRESHOLD, 11);
parameters.set(KEY.MAX_NEW_SYNAPSE_COUNT, 11);
parameters.set(KEY.PERMANENCE_INCREMENT, 0.4);
parameters.set(KEY.PERMANENCE_DECREMENT, 0.0);
parameters.set(KEY.ACTIVATION_THRESHOLD, 11);
if(overrides != null) {
parameters.union(overrides);
}
return parameters;
}
示例9: getLoadedDayOfWeekNetwork
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
private Network getLoadedDayOfWeekNetwork() {
Parameters p = NetworkTestHarness.getParameters().copy();
p = p.union(NetworkTestHarness.getDayDemoTestEncoderParams());
p.set(KEY.RANDOM, new FastRandom(42));
Sensor<ObservableSensor<String[]>> sensor = Sensor.create(
ObservableSensor::create, SensorParams.create(Keys::obs, new Object[] {"name",
PublisherSupplier.builder()
.addHeader("dayOfWeek")
.addHeader("number")
.addHeader("B").build() }));
Network network = Network.create("test network", p).add(Network.createRegion("r1")
.add(Network.createLayer("1", p)
.alterParameter(KEY.AUTO_CLASSIFY, true)
.add(Anomaly.create())
.add(new TemporalMemory())
.add(new SpatialPooler())
.add(sensor)));
return network;
}
示例10: testDestroySegmentsWithTooFewSynapsesToBeMatching
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
@Test
public void testDestroySegmentsWithTooFewSynapsesToBeMatching() {
TemporalMemory tm = new TemporalMemory();
Connections cn = new Connections();
Parameters p = getDefaultParameters(null, KEY.INITIAL_PERMANENCE, .2);
p = getDefaultParameters(p, KEY.MAX_NEW_SYNAPSE_COUNT, 4);
p = getDefaultParameters(p, KEY.PREDICTED_SEGMENT_DECREMENT, 0.02);
p.apply(cn);
TemporalMemory.init(cn);
int[] prevActiveColumns = { 0 };
Cell[] prevActiveCells = { cn.getCell(0), cn.getCell(1), cn.getCell(2), cn.getCell(3) };
int[] activeColumns = { 2 };
Cell expectedActiveCell = cn.getCell(5);
DistalDendrite matchingSegment = cn.createSegment(cn.getCell(5));
cn.createSynapse(matchingSegment, prevActiveCells[0], .015);
cn.createSynapse(matchingSegment, prevActiveCells[1], .015);
cn.createSynapse(matchingSegment, prevActiveCells[2], .015);
cn.createSynapse(matchingSegment, prevActiveCells[3], .015);
tm.compute(cn, prevActiveColumns, true);
tm.compute(cn, activeColumns, true);
assertEquals(0, cn.numSegments(expectedActiveCell));
}
示例11: testNoNewSegmentIfNotEnoughWinnerCells
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
@Test
public void testNoNewSegmentIfNotEnoughWinnerCells() {
TemporalMemory tm = new TemporalMemory();
Connections cn = new Connections();
Parameters p = getDefaultParameters(null, KEY.MAX_NEW_SYNAPSE_COUNT, 3);
p.apply(cn);
TemporalMemory.init(cn);
int[] zeroColumns = {};
int[] activeColumns = { 0 };
tm.compute(cn, zeroColumns, true);
tm.compute(cn, activeColumns, true);
assertEquals(0, cn.numSegments(), 0);
}
示例12: testPotentialRadiusFollowsInputWidth
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
@Test
public void testPotentialRadiusFollowsInputWidth() {
Parameters p = NetworkTestHarness.getParameters();
p = p.union(NetworkTestHarness.getNetworkDemoTestEncoderParams());
p.set(KEY.INPUT_DIMENSIONS, new int[] { 200 });
p.set(KEY.RANDOM, new MersenneTwister(42));
Network network = Network.create("test network", p)
.add(Network.createRegion("r1")
.add(Network.createLayer("2", p)
.add(Anomaly.create())
.add(new TemporalMemory())
.add(new SpatialPooler())
.close()));
Region r1 = network.lookup("r1");
Layer<?> layer2 = r1.lookup("2");
int width = layer2.calculateInputWidth();
assertEquals(200, width);
assertEquals(200, layer2.getConnections().getPotentialRadius());
}
示例13: testCalculateInputWidth_NoPrevLayer_NoPrevRegion_andSPTM
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
@Test
public void testCalculateInputWidth_NoPrevLayer_NoPrevRegion_andSPTM() {
Parameters p = NetworkTestHarness.getParameters();
p = p.union(NetworkTestHarness.getNetworkDemoTestEncoderParams());
p.set(KEY.RANDOM, new MersenneTwister(42));
Network network = Network.create("test network", p)
.add(Network.createRegion("r1")
.add(Network.createLayer("2", p)
.add(Anomaly.create())
.add(new TemporalMemory())
.add(new SpatialPooler())
.close()));
Region r1 = network.lookup("r1");
Layer<?> layer2 = r1.lookup("2");
int width = layer2.calculateInputWidth();
assertEquals(8, width);
assertEquals(8, layer2.getConnections().getPotentialRadius());
}
示例14: testCalculateInputWidth_NoPrevLayer_NoPrevRegion_andNoTM
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
@Test
public void testCalculateInputWidth_NoPrevLayer_NoPrevRegion_andNoTM() {
Parameters p = NetworkTestHarness.getParameters();
p = p.union(NetworkTestHarness.getNetworkDemoTestEncoderParams());
p.set(KEY.RANDOM, new MersenneTwister(42));
Network network = Network.create("test network", p)
.add(Network.createRegion("r1")
.add(Network.createLayer("2", p)
.add(Anomaly.create())
.add(new SpatialPooler())
.close()));
Region r1 = network.lookup("r1");
Layer<?> layer2 = r1.lookup("2");
int width = layer2.calculateInputWidth();
assertEquals(8, width);
assertEquals(8, layer2.getConnections().getPotentialRadius());
}
示例15: testMapPotential1Column1Input
import org.numenta.nupic.Parameters.KEY; //导入依赖的package包/类
@Test
public void testMapPotential1Column1Input() {
setupParameters();
parameters.setInputDimensions(new int[] { 1 });
parameters.setColumnDimensions(new int[] { 1 });
parameters.setPotentialRadius(2);
parameters.setPotentialPct(1);
parameters.set(KEY.WRAP_AROUND, false);
initSP();
//Test without wrapAround and potentialPct = 1
int[] expectedMask = new int[] { 0 };
int[] mask = sp.mapPotential(mem, 0, false);
TIntHashSet trueIndices = new TIntHashSet(expectedMask);
TIntHashSet maskSet = new TIntHashSet(mask);
// The *position* of the one "on" bit expected.
// Python version returns [1] which is the on bit in the zero'th position
assertTrue(trueIndices.equals(maskSet));
}