/**
   * Feeds a single array of phrase words into the {@link Network}.
   *
   * @param network
   * @param phrase
   */
  void feedLine(Network network, String[] phrase) {
    for (String term : phrase) {
      int[] sdr = getFingerprintSDR(term);
      // System.out.println(String.format("SDR for '%s'\t%d",term,sdr.length));
      network.compute(sdr);
    }

    network.reset();
  }
Beispiel #2
0
  @Ignore
  public void testPlayground() {
    final int NUM_CYCLES = 600;
    final int INPUT_GROUP_COUNT = 7; // Days of Week

    ///////////////////////////////////////
    //          Load a Network           //
    ///////////////////////////////////////
    Network network = getLoadedDayOfWeekNetwork();

    int cellsPerCol = (int) network.getParameters().get(KEY.CELLS_PER_COLUMN);

    network
        .observe()
        .subscribe(
            new Observer<Inference>() {
              @Override
              public void onCompleted() {}

              @Override
              public void onError(Throwable e) {
                e.printStackTrace();
              }

              @SuppressWarnings("unused")
              @Override
              public void onNext(Inference inf) {
                /** see {@link #createDayOfWeekInferencePrintout()} */
                int cycle = dayOfWeekPrintout.apply(inf, cellsPerCol);
              }
            });

    Publisher pub = network.getPublisher();

    network.start();

    int cycleCount = 0;
    for (; cycleCount < NUM_CYCLES; cycleCount++) {
      for (double j = 0; j < INPUT_GROUP_COUNT; j++) {
        pub.onNext("" + j);
      }

      network.reset();
    }

    // Test network output
    try {
      Region r1 = network.lookup("r1");
      r1.lookup("1").getLayerThread().join(2000);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }