예제 #1
0
  @Override
  protected void init() {

    metricsPE = new MetricsPE(this);

    Stream<ResultEvent> resultStream =
        new Stream<ResultEvent>(this, "Result Stream", new ResultKeyFinder(), metricsPE);

    modelPE = new ModelPE(this, model, numVectors);

    assignmentStream =
        new Stream<ObsEvent>(this, "Assignment Stream", new ClassIDKeyFinder(), modelPE);

    MaximizerPE minimizerPE = new MaximizerPE(this, numClasses, assignmentStream);

    Stream<ObsEvent> distanceStream =
        new Stream<ObsEvent>(this, "Distance Stream", new ObsIndexKeyFinder(), minimizerPE);

    /*
     * There is a loop in this graph so we need to set the stream at the
     * end. Is there a cleaner way to do this?
     */
    modelPE.setStream(distanceStream, resultStream);
    // modelPE.setOutputIntervalInEvents(10); // output every 10 events
    metricsPE.setOutputInterval(outputInterval, timeUnit); // output every 5
    // seconds
    // obsStream = new Stream<ObsEvent>(this, "Observation Stream", new
    // ClassIDKeyFinder(), modelPE);
    obsStream = new Stream<ObsEvent>(this, "Observation Stream", modelPE);
  }
예제 #2
0
  /**
   * Check if a training iteration is completed.
   *
   * @param iteration
   * @return true when a training iteration is completed.
   */
  public boolean isTrained(int iteration) {

    int sum = 0;
    for (ProcessingElement pe : modelPE.getRemoteInstances().values()) {
      sum += ((ModelPE) pe).getIteration();
    }
    if (sum < iteration * numClasses) return false;
    else return true;
  }
예제 #3
0
 /** @return true if modelPE is initialized. */
 public boolean isInited() {
   if (modelPE.getRemoteInstances().size() == numClasses) return true;
   else return false;
 }
예제 #4
0
  public long getObsCount() {

    return modelPE.getObsCount();
  }