def PositivePhase(self, train=False, evaluate=False, step=0):
    """Perform the positive phase.

    This method computes the sufficient statistics under the data distribution.
    """

    # Do a forward pass in the initializer net, if set.
    if self.initializer_net:
      self.initializer_net.ForwardPropagate(train=train, step=step)

    # Initialize layers.
    for node in self.node_list:
      if node.is_input:
        # Load data into input nodes.
        self.ComputeUp(node, train=train)
      elif node.is_initialized:
        node.state.assign(node.initialization_source.state)
      else:
        # Initialize other nodes to zero.
        node.ResetState(rand=False)

    # Starting MF.
    for i in range(self.net.hyperparams.mf_steps):
      for node in self.pos_phase_order:
        self.ComputeUp(node, train=train, step=step, maxsteps=self.train_stop_steps)
    # End of MF.

    losses = []
    if train:
      for node in self.layer:
        r = node.CollectSufficientStatistics()
        if r is not None:  # This is true only if sparsity is active.
          perf = deepnet_pb2.Metrics()
          perf.MergeFrom(node.proto.performance_stats)
          perf.count = 1
          perf.sparsity = r
          losses.append(perf)
      for edge in self.edge:
        edge.CollectSufficientStatistics()

    # Evaluation
    # If CD, then this step would be performed by the negative phase anyways,
    # So the loss is measured in the negative phase instead. Return []
    # Otherwise, reconstruct the input given the other layers and report
    # the loss.
    if not self.cd or evaluate:
      for node in self.input_datalayer:
        self.ComputeUp(node, compute_input=True, step=step, maxsteps=self.train_stop_steps)
        losses.append(node.GetLoss())
    return losses
Perform the positive phase.

    This method computes the sufficient statistics under the data distribution.
    
deepnet/dbm.py