parameters: (model_fns)
return_statement: return _model_fn
docstring: Get a combined model function given a list of other model fns.
  
    The model function returned will call the individual model functions and
    combine them appropriately.  For:
  
    training ops: tf.group them.
    loss: average them.
    predictions: concat probabilities such that predictions[*][0-C1] are the
      probablities for output 1 (where C1 is the number of classes in output 1),
      predictions[*][C1-(C1+C2)] are the probabilities for output 2 (where C2
      is the number of classes in output 2), etc.  Also stack predictions such
      that predictions[i][j] is the class prediction for example i and output j.
  
    This assumes that labels are 2-dimensional, with labels[i][j] being the
    label for example i and output j, where forest j is trained using only
    output j.
  
    Args:
      model_fns: A list of model functions obtained from get_model_fn.
  
    Returns:
      A ModelFnOps instance.
docstring_summary: Get a combined model function given a list of other model fns.
docstring_tokens: Get a combined model function given a list of other model fns .
function: def get_combined_model_fn(model_fns):
    """Get a combined model function given a list of other model fns.
  
    The model function returned will call the individual model functions and
    combine them appropriately.  For:
  
    training ops: tf.group them.
    loss: average them.
    predictions: concat probabilities such that predictions[*][0-C1] are the
      probablities for output 1 (where C1 is the number of classes in output 1),
      predictions[*][C1-(C1+C2)] are the probabilities for output 2 (where C2
      is the number of classes in output 2), etc.  Also stack predictions such
      that predictions[i][j] is the class prediction for example i and output j.
  
    This assumes that labels are 2-dimensional, with labels[i][j] being the
    label for example i and output j, where forest j is trained using only
    output j.
  
    Args:
      model_fns: A list of model functions obtained from get_model_fn.
  
    Returns:
      A ModelFnOps instance.
    """
    def _model_fn(features, labels, mode):
      """Function that returns predictions, training loss, and training op."""
      model_fn_ops = []
      for i in range(len(model_fns)):
        with variable_scope.variable_scope('label_{0}'.format(i)):
          sliced_labels = array_ops.slice(labels, [0, i], [-1, 1])
          model_fn_ops.append(
              model_fns[i](features, sliced_labels, mode))
      training_hooks = []
      for mops in model_fn_ops:
        training_hooks += mops.training_hooks
      predictions = {}
      if (mode == model_fn_lib.ModeKeys.EVAL or
          mode == model_fn_lib.ModeKeys.INFER):
        # Flatten the probabilities into one dimension.
        predictions[eval_metrics.INFERENCE_PROB_NAME] = array_ops.concat(
            [mops.predictions[eval_metrics.INFERENCE_PROB_NAME]
             for mops in model_fn_ops], axis=1)
        predictions[eval_metrics.INFERENCE_PRED_NAME] = array_ops.stack(
            [mops.predictions[eval_metrics.INFERENCE_PRED_NAME]
             for mops in model_fn_ops], axis=1)
      loss = None
      if (mode == model_fn_lib.ModeKeys.EVAL or
          mode == model_fn_lib.ModeKeys.TRAIN):
        loss = math_ops.reduce_sum(
            array_ops.stack(
                [mops.loss for mops in model_fn_ops])) / len(model_fn_ops)
  
      train_op = None
      if mode == model_fn_lib.ModeKeys.TRAIN:
        train_op = control_flow_ops.group(
            *[mops.train_op for mops in model_fn_ops])
      return model_fn_lib.ModelFnOps(
          mode=mode,
          predictions=predictions,
          loss=loss,
          train_op=train_op,
          training_hooks=training_hooks,
          scaffold=None,
          output_alternatives=None)
  
    return _model_fn
function_tokens: def get_combined_model_fn ( model_fns ) : def _model_fn ( features , labels , mode ) : """Function that returns predictions, training loss, and training op.""" model_fn_ops = [ ] for i in range ( len ( model_fns ) ) : with variable_scope . variable_scope ( 'label_{0}' . format ( i ) ) : sliced_labels = array_ops . slice ( labels , [ 0 , i ] , [ - 1 , 1 ] ) model_fn_ops . append ( model_fns [ i ] ( features , sliced_labels , mode ) ) training_hooks = [ ] for mops in model_fn_ops : training_hooks += mops . training_hooks predictions = { } if ( mode == model_fn_lib . ModeKeys . EVAL or mode == model_fn_lib . ModeKeys . INFER ) : # Flatten the probabilities into one dimension. predictions [ eval_metrics . INFERENCE_PROB_NAME ] = array_ops . concat ( [ mops . predictions [ eval_metrics . INFERENCE_PROB_NAME ] for mops in model_fn_ops ] , axis = 1 ) predictions [ eval_metrics . INFERENCE_PRED_NAME ] = array_ops . stack ( [ mops . predictions [ eval_metrics . INFERENCE_PRED_NAME ] for mops in model_fn_ops ] , axis = 1 ) loss = None if ( mode == model_fn_lib . ModeKeys . EVAL or mode == model_fn_lib . ModeKeys . TRAIN ) : loss = math_ops . reduce_sum ( array_ops . stack ( [ mops . loss for mops in model_fn_ops ] ) ) / len ( model_fn_ops ) train_op = None if mode == model_fn_lib . ModeKeys . TRAIN : train_op = control_flow_ops . group ( * [ mops . train_op for mops in model_fn_ops ] ) return model_fn_lib . ModelFnOps ( mode = mode , predictions = predictions , loss = loss , train_op = train_op , training_hooks = training_hooks , scaffold = None , output_alternatives = None ) return _model_fn