def ForwardPropagate(self, train=False, method='iter'):
    """Loads input and computes the sparse code for it."""

    input_layer = self.input_layer
    code_layer = self.code_layer

    # Load data into state.
    input_layer.GetData()

    # Run it through the encoder.
    inputs = input_layer.state
    we = self.encoder.params['weight']
    be = code_layer.params['bias']
    scale = code_layer.params['scale']
    hyp = code_layer.hyperparams
    code_approx = code_layer.approximator
    cm.dot(we.T, inputs, target=code_approx)
    code_approx.add_col_vec(be)
    code_layer.ApplyActivation(code_approx)
    code_approx.mult_by_col(scale)
    if hyp.dropout and train:
      code_layer.mask.fill_with_rand()
      code_layer.mask.greater_than(hyp.dropout_prob)
      code_approx.mult(code_layer.mask)

    # Infer z.
    if train:
      if method == 'iter':
        self.IterateForZ(train=train)
      elif method == 'exact':
        self.SolveForZ()
    else:
      if method == 'iter':
        self.IterateForZ(train=train)
      #code_layer.state.assign(code_approx)
Loads input and computes the sparse code for it.
deepnet/sparse_coder.py