Beispiel #1
0
  ///////////////////////////////////////////
  //             HELPER METHODS            //
  ///////////////////////////////////////////
  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;
  }
  @Test
  public void testUnion() {
    Parameters params = Parameters.getAllDefaultParameters();
    Parameters arg = Parameters.getAllDefaultParameters();
    arg.setParameterByKey(KEY.CELLS_PER_COLUMN, 5);

    assertTrue((int) params.getParameterByKey(KEY.CELLS_PER_COLUMN) != 5);
    params.union(arg);
    assertTrue((int) params.getParameterByKey(KEY.CELLS_PER_COLUMN) == 5);
  }