parameters: (self,
                       input_data,
                       input_labels,
                       num_trainers=1,
                       trainer_id=0,
                       **tree_kwargs)
return_statement: return control_flow_ops.group(*tree_graphs, name='train')
docstring: Constructs a TF graph for training a random forest.
  
      Args:
        input_data: A tensor or dict of string->Tensor for input data.
        input_labels: A tensor or placeholder for labels associated with
          input_data.
        num_trainers: Number of parallel trainers to split trees among.
        trainer_id: Which trainer this instance is.
        **tree_kwargs: Keyword arguments passed to each tree's training_graph.
  
      Returns:
        The last op in the random forest training graph.
  
      Raises:
        NotImplementedError: If trying to use bagging with sparse features.
docstring_summary: Constructs a TF graph for training a random forest.
docstring_tokens: Constructs a TF graph for training a random forest .
function: def training_graph(self,
                       input_data,
                       input_labels,
                       num_trainers=1,
                       trainer_id=0,
                       **tree_kwargs):
      """Constructs a TF graph for training a random forest.
  
      Args:
        input_data: A tensor or dict of string->Tensor for input data.
        input_labels: A tensor or placeholder for labels associated with
          input_data.
        num_trainers: Number of parallel trainers to split trees among.
        trainer_id: Which trainer this instance is.
        **tree_kwargs: Keyword arguments passed to each tree's training_graph.
  
      Returns:
        The last op in the random forest training graph.
  
      Raises:
        NotImplementedError: If trying to use bagging with sparse features.
      """
      processed_dense_features, processed_sparse_features, data_spec = (
          data_ops.ParseDataTensorOrDict(input_data))
  
      if input_labels is not None:
        labels = data_ops.ParseLabelTensorOrDict(input_labels)
  
      data_spec = data_spec or self.get_default_data_spec(input_data)
  
      tree_graphs = []
      trees_per_trainer = self.params.num_trees / num_trainers
      tree_start = int(trainer_id * trees_per_trainer)
      tree_end = int((trainer_id + 1) * trees_per_trainer)
      for i in range(tree_start, tree_end):
        with ops.device(self.variables.device_dummies[i].device):
          seed = self.params.base_random_seed
          if seed != 0:
            seed += i
          # If using bagging, randomly select some of the input.
          tree_data = processed_dense_features
          tree_labels = labels
          if self.params.bagging_fraction < 1.0:
            # TODO(gilberth): Support bagging for sparse features.
            if processed_sparse_features is not None:
              raise NotImplementedError(
                  'Bagging not supported with sparse features.')
            # TODO(thomaswc): This does sampling without replacement.  Consider
            # also allowing sampling with replacement as an option.
            batch_size = array_ops.strided_slice(
                array_ops.shape(processed_dense_features), [0], [1])
            r = random_ops.random_uniform(batch_size, seed=seed)
            mask = math_ops.less(
                r, array_ops.ones_like(r) * self.params.bagging_fraction)
            gather_indices = array_ops.squeeze(
                array_ops.where(mask), squeeze_dims=[1])
            # TODO(thomaswc): Calculate out-of-bag data and labels, and store
            # them for use in calculating statistics later.
            tree_data = array_ops.gather(processed_dense_features, gather_indices)
            tree_labels = array_ops.gather(labels, gather_indices)
          if self.params.bagged_features:
            if processed_sparse_features is not None:
              raise NotImplementedError(
                  'Feature bagging not supported with sparse features.')
            tree_data = self._bag_features(i, tree_data)
  
          tree_graphs.append(self.trees[i].training_graph(
              tree_data,
              tree_labels,
              seed,
              data_spec=data_spec,
              sparse_features=processed_sparse_features,
              **tree_kwargs))
  
      return control_flow_ops.group(*tree_graphs, name='train')
function_tokens: def training_graph ( self , input_data , input_labels , num_trainers = 1 , trainer_id = 0 , * * tree_kwargs ) : processed_dense_features , processed_sparse_features , data_spec = ( data_ops . ParseDataTensorOrDict ( input_data ) ) if input_labels is not None : labels = data_ops . ParseLabelTensorOrDict ( input_labels ) data_spec = data_spec or self . get_default_data_spec ( input_data ) tree_graphs = [ ] trees_per_trainer = self . params . num_trees / num_trainers tree_start = int ( trainer_id * trees_per_trainer ) tree_end = int ( ( trainer_id + 1 ) * trees_per_trainer ) for i in range ( tree_start , tree_end ) : with ops . device ( self . variables . device_dummies [ i ] . device ) : seed = self . params . base_random_seed if seed != 0 : seed += i # If using bagging, randomly select some of the input. tree_data = processed_dense_features tree_labels = labels if self . params . bagging_fraction < 1.0 : # TODO(gilberth): Support bagging for sparse features. if processed_sparse_features is not None : raise NotImplementedError ( 'Bagging not supported with sparse features.' ) # TODO(thomaswc): This does sampling without replacement.  Consider # also allowing sampling with replacement as an option. batch_size = array_ops . strided_slice ( array_ops . shape ( processed_dense_features ) , [ 0 ] , [ 1 ] ) r = random_ops . random_uniform ( batch_size , seed = seed ) mask = math_ops . less ( r , array_ops . ones_like ( r ) * self . params . bagging_fraction ) gather_indices = array_ops . squeeze ( array_ops . where ( mask ) , squeeze_dims = [ 1 ] ) # TODO(thomaswc): Calculate out-of-bag data and labels, and store # them for use in calculating statistics later. tree_data = array_ops . gather ( processed_dense_features , gather_indices ) tree_labels = array_ops . gather ( labels , gather_indices ) if self . params . bagged_features : if processed_sparse_features is not None : raise NotImplementedError ( 'Feature bagging not supported with sparse features.' ) tree_data = self . _bag_features ( i , tree_data ) tree_graphs . append ( self . trees [ i ] . training_graph ( tree_data , tree_labels , seed , data_spec = data_spec , sparse_features = processed_sparse_features , * * tree_kwargs ) ) return control_flow_ops . group ( * tree_graphs , name = 'train' )