Conduct forward pass using the stored inputs

@param train If true: do forward pass at training time; false: do forward pass at test time
@return A map of activations for each layer (not each GraphVertex). Keys = layer name, values = layer activations
765652
public Map<String, INDArray> feedForward(boolean train) {
        try {
            return ffToLayerActivationsDetached(train, FwdPassType.STANDARD, false, vertices.length - 1,
                    null, inputs, inputMaskArrays, labelMaskArrays, true);
        } catch (OutOfMemoryError e){
            CrashReportingUtil.writeMemoryCrashDump(this, e);
            throw e;
        }
    }
1065244
def forward_state(self, sequence, state=None):
        
        if state is None:
            state = self.zero_state(sequence.size(0))

        data = self.input_block(sequence)

        state_outputs = []

        # for layer_length, layer in zip(self.hidden_layers, self.recurrent_layers):
        for idx in range(len(self.recurrent_layers)):
            layer_length = self.recurrent_layers[idx].state_dim

            # Partition hidden state, for each layer we have layer_length of h state and layer_length of c state
            current_state = state[:, :, :layer_length]
            state = state[:, :, layer_length:]

            # Propagate through the GRU state
            data, new_h = self.recurrent_layers[idx](data, current_state)

            if self.dropout_layers:
                data = self.dropout_layers[idx](data)

            state_outputs.append(new_h)

        output_data = self.output_activation(self.output_layer(data))

        concatenated_hidden_output = torch.cat(state_outputs, dim=2)

        return output_data, concatenated_hidden_output
991631
@Override
    public Tensor forward() {
        Tensor x = modInX.getOutput();
        y = new Tensor(x); // copy
        y.exp();
        return y;
    }
444449
def forward(inputs_i, Q, G, A, b, h, U_Q, U_S, R, verbose=False):
    
    nineq, nz, neq, _ = get_sizes(G, A)

    # find initial values
    d = torch.ones(nineq).type_as(Q)
    nb = -b if b is not None else None
    factor_kkt(U_S, R, d)
    x, s, z, y = solve_kkt(
        U_Q, d, G, A, U_S,
        inputs_i, torch.zeros(nineq).type_as(Q), -h, nb)
    # x1, s1, z1, y1 = factor_solve_kkt(Q, torch.eye(nineq).type_as(Q), G, A, inputs_i,
    # torch.zeros(nineq).type_as(Q), -h, nb)

    if torch.min(s) < 0:
        s -= torch.min(s) - 1
    if torch.min(z) < 0:
        z -= torch.min(z) - 1

    prev_resid = None
    for i in range(20):
        # affine scaling direction
        rx = (torch.mv(A.t(), y) if neq > 0 else 0.) + \
            torch.mv(G.t(), z) + torch.mv(Q, x) + inputs_i
        rs = z
        rz = torch.mv(G, x) + s - h
        ry = torch.mv(A, x) - b if neq > 0 else torch.Tensor([0.])
        mu = torch.dot(s, z) / nineq
        pri_resid = torch.norm(ry) + torch.norm(rz)
        dual_resid = torch.norm(rx)
        resid = pri_resid + dual_resid + nineq * mu
        d = z / s
        if verbose:
            print(("primal_res = {0:.5g}, dual_res = {1:.5g}, " +
                   "gap = {2:.5g}, kappa(d) = {3:.5g}").format(
                pri_resid, dual_resid, mu, min(d) / max(d)))
        # if (pri_resid < 5e-4 and dual_resid < 5e-4 and mu < 4e-4):
        improved = (prev_resid is None) or (resid < prev_resid + 1e-6)
        if not improved or resid < 1e-6:
            return x, y, z
        prev_resid = resid

        factor_kkt(U_S, R, d)
        dx_aff, ds_aff, dz_aff, dy_aff = solve_kkt(U_Q, d, G, A, U_S,
                                                   rx, rs, rz, ry)
        # D = torch.diag((z/s).cpu()).type_as(Q)
        # dx_aff1, ds_aff1, dz_aff1, dy_aff1 = factor_solve_kkt(Q, D, G, A, rx, rs, rz, ry)

        # compute centering directions
        alpha = min(min(get_step(z, dz_aff), get_step(s, ds_aff)), 1.0)
        sig = (torch.dot(s + alpha * ds_aff, z +
                         alpha * dz_aff) / (torch.dot(s, z)))**3
        dx_cor, ds_cor, dz_cor, dy_cor = solve_kkt(
            U_Q, d, G, A, U_S, torch.zeros(nz).type_as(Q),
            (-mu * sig * torch.ones(nineq).type_as(Q) + ds_aff * dz_aff) / s,
            torch.zeros(nineq).type_as(Q), torch.zeros(neq).type_as(Q))
        # dx_cor, ds_cor, dz_cor, dy_cor = factor_solve_kkt(Q, D, G, A,
        #     torch.zeros(nz).type_as(Q),
        #     (-mu*sig*torch.ones(nineq).type_as(Q) + ds_aff*dz_aff)/s,
        #     torch.zeros(nineq).type_as(Q), torch.zeros(neq).type_as(Q))

        dx = dx_aff + dx_cor
        ds = ds_aff + ds_cor
        dz = dz_aff + dz_cor
        dy = dy_aff + dy_cor if neq > 0 else None
        alpha = min(1.0, 0.999 * min(get_step(s, ds), get_step(z, dz)))
        dx_norm = torch.norm(dx)
        dz_norm = torch.norm(dz)
        if np.isnan(dx_norm) or dx_norm > 1e5 or dz_norm > 1e5:
            # Overflow, return early
            return x, y, z

        x += alpha * dx
        s += alpha * ds
        z += alpha * dz
        y = y + alpha * dy if neq > 0 else None

    return x, y, z
734278
def on_train_begin(self, **kwargs):
        ""
        self.G_A,self.G_B = self.learn.model.G_A,self.learn.model.G_B
        self.D_A,self.D_B = self.learn.model.D_A,self.learn.model.D_B
        self.crit = self.learn.loss_func.crit
        self.opt_G = self.learn.opt.new([nn.Sequential(*flatten_model(self.G_A), *flatten_model(self.G_B))])
        self.opt_D_A = self.learn.opt.new([nn.Sequential(*flatten_model(self.D_A))])
        self.opt_D_B = self.learn.opt.new([nn.Sequential(*flatten_model(self.D_B))])
        self.learn.opt.opt = self.opt_G.opt
        self._set_trainable()
        self.names = ['idt_loss', 'gen_loss', 'cyc_loss', 'da_loss', 'db_loss']
        self.learn.recorder.no_val=True
        self.learn.recorder.add_metric_names(self.names)
        self.smootheners = {n:SmoothenValue(0.98) for n in self.names}
838518
private ForwardStepResult<S, O, D> forwardStep(O observation, Collection<S> prevCandidates,
            Collection<S> curCandidates, Map<S, Double> message,
            Map<S, Double> emissionLogProbabilities,
            Map<Transition<S>, Double> transitionLogProbabilities,
            Map<Transition<S>,D> transitionDescriptors) {
        final ForwardStepResult<S, O, D> result = new ForwardStepResult<>(curCandidates.size());
        assert !prevCandidates.isEmpty();

        for (S curState : curCandidates) {
            double maxLogProbability = Double.NEGATIVE_INFINITY;
            S maxPrevState = null;
            for (S prevState : prevCandidates) {
                final double logProbability = message.get(prevState) + transitionLogProbability(
                        prevState, curState, transitionLogProbabilities);
                if (logProbability > maxLogProbability) {
                    maxLogProbability = logProbability;
                    maxPrevState = prevState;
                }
            }
            // Throws NullPointerException if curState is not stored in the map.
            result.newMessage.put(curState, maxLogProbability
                    + emissionLogProbabilities.get(curState));

            // Note that maxPrevState == null if there is no transition with non-zero probability.
            // In this case curState has zero probability and will not be part of the most likely
            // sequence, so we don't need an ExtendedState.
            if (maxPrevState != null) {
                final Transition<S> transition = new Transition<>(maxPrevState, curState);
                final ExtendedState<S, O, D> extendedState = new ExtendedState<>(curState,
                        lastExtendedStates.get(maxPrevState), observation,
                        transitionDescriptors.get(transition));
                result.newExtendedStates.put(curState, extendedState);
            }
        }
        return result;
    }
101428
def _forward(self, x_dot_parameters):
        
        return forward(self._lattice, x_dot_parameters, 
                       self.state_machine.n_states)
295540
def on_train_begin(self, epoch:int, **kwargs:Any)->None:
        ""
        res = {'epoch':self.start_epoch} if self.start_epoch is not None else None
        self.start_epoch = ifnone(self.start_epoch, epoch)
        self.scheds = [p.scheds for p in self.phases]
        self.opt = self.learn.opt
        for k,v in self.scheds[0].items(): 
            v.restart()
            self.opt.set_stat(k, v.start)
        self.idx_s = 0
        return res
462997
def forward(self, data_batch, is_train=None, carry_state=True):
        
        # propagate states from the previous iteration
        if carry_state:
            if isinstance(self._next_states, (int, float)):
                self._module.set_states(value=self._next_states)
            else:
                self._module.set_states(states=self._next_states)
        self._module.forward(data_batch, is_train=is_train)
        outputs = self._module.get_outputs(merge_multi_context=False)
        self._next_states = outputs[:-1]
71426
public static int cudnnPoolingForward(
        cudnnHandle handle, 
        cudnnPoolingDescriptor poolingDesc, 
        Pointer alpha, 
        cudnnTensorDescriptor xDesc, 
        Pointer x, 
        Pointer beta, 
        cudnnTensorDescriptor yDesc, 
        Pointer y)
    {
        return checkResult(cudnnPoolingForwardNative(handle, poolingDesc, alpha, xDesc, x, beta, yDesc, y));
    }
1017580
public final DeepLearningModel trainModel(DeepLearningModel model) {
    Frame validScoreFrame = null;
    Frame train, trainScoreFrame;
    try {
      lock_data();
      if (checkpoint == null && !quiet_mode) logStart(); //if checkpoint is given, some Job's params might be uninitialized (but the restarted model's parameters are correct)
      if (model == null) {
        model = UKV.get(dest());
      }
      model.write_lock(self());
      final DeepLearning mp = model.model_info().get_params(); //use the model's parameters for everything below - NOT the job's parameters (can be different after checkpoint restart)

      prepareValidationWithModel(model);
      final long model_size = model.model_info().size();
      if (!quiet_mode) Log.info("Number of model parameters (weights/biases): " + String.format("%,d", model_size));
      train = model.model_info().data_info()._adaptedFrame;
      if (mp.force_load_balance) train = updateFrame(train, reBalance(train, mp.replicate_training_data));
      if (mp.classification && mp.balance_classes) {
        float[] trainSamplingFactors = new float[train.lastVec().domain().length]; //leave initialized to 0 -> will be filled up below
        if (class_sampling_factors != null) {
          if (class_sampling_factors.length != train.lastVec().domain().length)
            throw new IllegalArgumentException("class_sampling_factors must have " + train.lastVec().domain().length + " elements");
          trainSamplingFactors = class_sampling_factors.clone(); //clone: don't modify the original
        }
        train = updateFrame(train, sampleFrameStratified(
                train, train.lastVec(), trainSamplingFactors, (long)(mp.max_after_balance_size*train.numRows()), mp.seed, true, false));
        model.setModelClassDistribution(new MRUtils.ClassDist(train.lastVec()).doAll(train.lastVec()).rel_dist());
      }
      model.training_rows = train.numRows();
      trainScoreFrame = updateFrame(train, sampleFrame(train, mp.score_training_samples, mp.seed)); //training scoring dataset is always sampled uniformly from the training dataset

      if (!quiet_mode) Log.info("Number of chunks of the training data: " + train.anyVec().nChunks());
      if (validation != null) {
        model.validation_rows = validation.numRows();
        Frame adaptedValid = getValidation();
        if (getValidAdaptor().needsAdaptation2CM()) {
          adaptedValid.add(getValidAdaptor().adaptedValidationResponse(_responseName), getValidAdaptor().getAdaptedValidationResponse2CM());
        }
        // validation scoring dataset can be sampled in multiple ways from the given validation dataset
        if (mp.classification && mp.balance_classes && mp.score_validation_sampling == ClassSamplingMethod.Stratified) {
          validScoreFrame = updateFrame(adaptedValid, sampleFrameStratified(adaptedValid, adaptedValid.lastVec(), null,
                  mp.score_validation_samples > 0 ? mp.score_validation_samples : adaptedValid.numRows(), mp.seed+1, false /* no oversampling */, false));
        } else {
          validScoreFrame = updateFrame(adaptedValid, sampleFrame(adaptedValid, mp.score_validation_samples, mp.seed+1));
        }
        if (mp.force_load_balance) validScoreFrame = updateFrame(validScoreFrame, reBalance(validScoreFrame, false /*always split up globally since scoring should be distributed*/));
        if (!quiet_mode) Log.info("Number of chunks of the validation data: " + validScoreFrame.anyVec().nChunks());
      }

      // Set train_samples_per_iteration size (cannot be done earlier since this depends on whether stratified sampling is done)
      model.actual_train_samples_per_iteration = computeTrainSamplesPerIteration(mp, train.numRows(), model);
      // Determine whether shuffling is enforced
      if(mp.replicate_training_data && (model.actual_train_samples_per_iteration == train.numRows()*(mp.single_node_mode?1:H2O.CLOUD.size())) && !mp.shuffle_training_data && H2O.CLOUD.size() > 1 && !mp.reproducible) {
        Log.warn("Enabling training data shuffling, because all nodes train on the full dataset (replicated training data).");
        mp.shuffle_training_data = true;
      }

      model._timeLastScoreEnter = System.currentTimeMillis(); //to keep track of time per iteration, must be called before first call to doScoring


      if (!mp.quiet_mode) Log.info("Initial model:\n" + model.model_info());
      if (autoencoder) model.doScoring(train, trainScoreFrame, validScoreFrame, self(), getValidAdaptor()); //get the null model reconstruction error
      // put the initial version of the model into DKV
      model.update(self());
      Log.info("Starting to train the Deep Learning model.");

      //main loop
      do model.set_model_info(H2O.CLOUD.size() > 1 && mp.replicate_training_data ? ( mp.single_node_mode ?
              new DeepLearningTask2(train, model.model_info(), rowFraction(train, mp, model)).invoke(Key.make()).model_info() : //replicated data + single node mode
              new DeepLearningTask2(train, model.model_info(), rowFraction(train, mp, model)).invokeOnAllNodes().model_info() ) : //replicated data + multi-node mode
              new DeepLearningTask(model.model_info(), rowFraction(train, mp, model)).doAll(train).model_info()); //distributed data (always in multi-node mode)
      while (model.doScoring(train, trainScoreFrame, validScoreFrame, self(), getValidAdaptor()));

      // replace the model with the best model so far (if it's better)
      if (!isCancelledOrCrashed() && override_with_best_model && model.actual_best_model_key != null && n_folds == 0) {
        DeepLearningModel best_model = UKV.get(model.actual_best_model_key);
        if (best_model != null && best_model.error() < model.error() && Arrays.equals(best_model.model_info().units, model.model_info().units)) {
          Log.info("Setting the model to be the best model so far (based on scoring history).");
          DeepLearningModel.DeepLearningModelInfo mi = best_model.model_info().deep_clone();
          // Don't cheat - count full amount of training samples, since that's the amount of training it took to train (without finding anything better)
          mi.set_processed_global(model.model_info().get_processed_global());
          mi.set_processed_local(model.model_info().get_processed_local());
          model.set_model_info(mi);
          model.update(self());
          model.doScoring(train, trainScoreFrame, validScoreFrame, self(), getValidAdaptor());
          assert(best_model.error() == model.error());
        }
      }

      Log.info(model);
      Log.info("Finished training the Deep Learning model.");
      return model;
    }
    catch(JobCancelledException ex) {
      model = UKV.get(dest());
      state = JobState.CANCELLED; //for JSON REST response
      model.get_params().state = state; //for parameter JSON on the HTML page
      Log.info("Deep Learning model building was cancelled.");
      return model;
    }
    catch(Throwable t) {
      t.printStackTrace();
      model = UKV.get(dest());
      state = JobState.FAILED; //for JSON REST response
      if (model != null) {
        model.get_params().state = state; //for parameter JSON on the HTML page
        Log.info("Deep Learning model building failed.");
      }
      return model;
    }
    finally {
      if (model != null && DKV.get(model._key) != null) model.unlock(self());
      unlock_data();
    }
  }
1013518
public Map addForwarding(Map params) throws Exception {
        CreateForwardingRulePayload payload = new CreateForwardingRulePayload();
        payload.setFromUser(parseUserMetaBackwardsCompatible(params.get(OpsGenieClientConstants.API.FROM_USER)));
        payload.setToUser(parseUserMetaBackwardsCompatible(params.get(OpsGenieClientConstants.API.TO_USER)));
        payload.setStartDate(ScriptBridgeUtils.getAsDateTime(params, OpsGenieClientConstants.API.START_DATE));
        payload.setEndDate(ScriptBridgeUtils.getAsDateTime(params, OpsGenieClientConstants.API.END_DATE));
        payload.setAlias(ScriptBridgeUtils.getAsString(params, OpsGenieClientConstants.API.ALIAS));

        return JsonUtils.toMap(forwardingRuleApi.createForwardingRule(payload));
    }
573136
public static IActivation mapToIActivation(String kerasActivation, KerasLayerConfiguration conf)
            throws UnsupportedKerasConfigurationException {
        Activation activation = mapToActivation(kerasActivation, conf);
        return activation.getActivationFunction();
    }
925420
public ActiveTunnel[] getLocalForwardingTunnels(String key)
			throws IOException {

		if (outgoingtunnels.containsKey(key)) {
			Vector<ActiveTunnel> v = outgoingtunnels.get(key);
			ActiveTunnel[] t = new ActiveTunnel[v.size()];
			v.copyInto(t);
			return t;
		}

		if (!socketlisteners.containsKey(key)) {
			throw new IOException(key
					+ " is not a valid local forwarding configuration");
		}

		return new ActiveTunnel[] {};
	}
1269309
def forward_all(collection)
      newcollection = collection.dup.clear
      collection.each do |point|
        newcollection << forward(point)
      end
      newcollection
    end
1369553
def forward(self, x):
        
        fwd = np.zeros((self.num_matrices, self.N, self.N), settings.float_type)
        indices = np.tril_indices(self.N, 0)
        z = np.zeros(len(indices[0])).astype(int)
        for i in range(self.num_matrices):
            fwd[(z + i,) + indices] = x[i, :]
        return fwd.squeeze(axis=0) if self.squeeze else fwd
152090
function forwardPass(graph, depEnds, tasks, start) {
    updateDependencies(depEnds, tasks, start);
    for(var i = 0, len = tasks.length; i < len; i++) {
      var tid = tasks[i],
          task = graph.tasks[tid],
          dependsOn = task.dependsOn,
          dep = depEnds[tid];

      if(!task.earlyFinish && (isEmpty(dependsOn) || (dep && dep[0] === dependsOn.length))) {
        task.earlyStart = dep[1];
        task.earlyFinish = dep[1] + task.duration;

        if(!isEmpty(task.requiredBy)) {
          forwardPass(graph, depEnds, task.requiredBy, task.earlyFinish);
        }
      }
    }
  }