當前位置: 首頁>>代碼示例>>Python>>正文


Python tensor_forest.RandomForestDeviceAssigner方法代碼示例

本文整理匯總了Python中tensorflow.contrib.tensor_forest.python.tensor_forest.RandomForestDeviceAssigner方法的典型用法代碼示例。如果您正苦於以下問題:Python tensor_forest.RandomForestDeviceAssigner方法的具體用法?Python tensor_forest.RandomForestDeviceAssigner怎麽用?Python tensor_forest.RandomForestDeviceAssigner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.contrib.tensor_forest.python.tensor_forest的用法示例。


在下文中一共展示了tensor_forest.RandomForestDeviceAssigner方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import RandomForestDeviceAssigner [as 別名]
def __init__(self,
               params,
               device_assigner=None,
               optimizer_class=adagrad.AdagradOptimizer,
               **kwargs):

    self.device_assigner = (
        device_assigner or tensor_forest.RandomForestDeviceAssigner())

    self.params = params

    self.optimizer = optimizer_class(self.params.learning_rate)

    self.is_regression = params.regression

    self.regularizer = None
    if params.regularization == "l1":
      self.regularizer = layers.l1_regularizer(
          self.params.regularization_strength)
    elif params.regularization == "l2":
      self.regularizer = layers.l2_regularizer(
          self.params.regularization_strength) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:24,代碼來源:hybrid_model.py

示例2: __init__

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import RandomForestDeviceAssigner [as 別名]
def __init__(self, params, device_assigner=None, model_dir=None,
               graph_builder_class=tensor_forest.RandomForestGraphs,
               master='', accuracy_metric=None,
               tf_random_seed=None, config=None):
    self.params = params.fill()
    self.accuracy_metric = (accuracy_metric or
                            ('r2' if self.params.regression else 'accuracy'))
    self.data_feeder = None
    self.device_assigner = (
        device_assigner or tensor_forest.RandomForestDeviceAssigner())
    self.graph_builder_class = graph_builder_class
    self.training_args = {}
    self.construction_args = {}

    super(TensorForestEstimator, self).__init__(model_dir=model_dir,
                                                config=config) 
開發者ID:lbkchen,項目名稱:deep-learning,代碼行數:18,代碼來源:rf3.py

示例3: __init__

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import RandomForestDeviceAssigner [as 別名]
def __init__(self, params, layer_num, device_assigner, *args, **kwargs):
    self.layer_num = layer_num
    self.device_assigner = (
        device_assigner or tensor_forest.RandomForestDeviceAssigner())
    self.params = params
    self._define_vars(params, **kwargs) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:8,代碼來源:hybrid_layer.py

示例4: export

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import RandomForestDeviceAssigner [as 別名]
def export(self,
             export_dir,
             input_fn,
             signature_fn=None,
             input_feature_key=None,
             default_batch_size=1):
    """See BaseEstimator.export."""
    # Reset model function with basic device assigner.
    # Servo doesn't support distributed inference
    # but it will try to respect device assignments if they're there.
    # pylint: disable=protected-access
    orig_model_fn = self._estimator._model_fn
    self._estimator._model_fn = get_model_fn(
        self.params, self.graph_builder_class,
        tensor_forest.RandomForestDeviceAssigner(),
        weights_name=self.weights_name)
    result = self._estimator.export(
        export_dir=export_dir,
        input_fn=input_fn,
        input_feature_key=input_feature_key,
        use_deprecated_input_fn=False,
        signature_fn=(signature_fn or
                      (export.regression_signature_fn
                       if self.params.regression else
                       export.classification_signature_fn_with_prob)),
        default_batch_size=default_batch_size,
        prediction_key=eval_metrics.INFERENCE_PROB_NAME)
    self._estimator._model_fn = orig_model_fn
    # pylint: enable=protected-access
    return result 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:32,代碼來源:random_forest.py

示例5: export

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import RandomForestDeviceAssigner [as 別名]
def export(self,
             export_dir,
             input_fn,
             signature_fn=None,
             default_batch_size=1):
    """See BaseEstimator.export."""
    # Reset model function with basic device assigner.
    # Servo doesn't support distributed inference
    # but it will try to respect device assignments if they're there.
    # pylint: disable=protected-access
    orig_model_fn = self._estimator._model_fn
    self._estimator._model_fn = get_model_fn(
        self.params, self.graph_builder_class,
        tensor_forest.RandomForestDeviceAssigner(),
        weights_name=self.weights_name)
    result = self._estimator.export(
        export_dir=export_dir,
        use_deprecated_input_fn=True,
        signature_fn=(signature_fn or
                      (export.regression_signature_fn
                       if self.params.regression else
                       export.classification_signature_fn_with_prob)),
        default_batch_size=default_batch_size,
        prediction_key=eval_metrics.INFERENCE_PROB_NAME)
    self._estimator._model_fn = orig_model_fn
    # pylint: enable=protected-access
    return result 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:29,代碼來源:random_forest.py

示例6: __init__

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import RandomForestDeviceAssigner [as 別名]
def __init__(self, params, device_assigner=None, model_dir=None,
               graph_builder_class=tensor_forest.RandomForestGraphs,
               config=None, weights_name=None, keys_name=None,
               feature_engineering_fn=None, early_stopping_rounds=100,
               num_trainers=1, trainer_id=0):

    """Initializes a TensorForestEstimator instance.

    Args:
      params: ForestHParams object that holds random forest hyperparameters.
        These parameters will be passed into `model_fn`.
      device_assigner: An `object` instance that controls how trees get
        assigned to devices. If `None`, will use
        `tensor_forest.RandomForestDeviceAssigner`.
      model_dir: Directory to save model parameters, graph, etc. To continue
        training a previously saved model, load checkpoints saved to this
        directory into an estimator.
      graph_builder_class: An `object` instance that defines how TF graphs for
        random forest training and inference are built. By default will use
        `tensor_forest.RandomForestGraphs`.
      config: `RunConfig` object to configure the runtime settings.
      weights_name: A string defining feature column name representing
        weights. Will be multiplied by the loss of the example. Used to
        downweight or boost examples during training.
      keys_name: A string defining feature column name representing example
        keys. Used by `predict_with_keys` method.
      feature_engineering_fn: Feature engineering function. Takes features and
        labels which are the output of `input_fn` and returns features and
        labels which will be fed into the model.
      early_stopping_rounds: Allows training to terminate early if the forest is
        no longer growing. 100 by default.
      num_trainers: Number of training jobs, which will partition trees
        among them.
      trainer_id: Which trainer this instance is.

    Returns:
      A `TensorForestEstimator` instance.
    """
    self.params = params.fill()
    self.graph_builder_class = graph_builder_class
    self.early_stopping_rounds = early_stopping_rounds
    self.weights_name = weights_name
    self._estimator = estimator.Estimator(
        model_fn=get_model_fn(params, graph_builder_class, device_assigner,
                              weights_name=weights_name, keys_name=keys_name,
                              num_trainers=num_trainers, trainer_id=trainer_id),
        model_dir=model_dir,
        config=config,
        feature_engineering_fn=feature_engineering_fn)
    self._skcompat = estimator.SKCompat(self._estimator) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:52,代碼來源:random_forest.py

示例7: __init__

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import RandomForestDeviceAssigner [as 別名]
def __init__(self, params, device_assigner=None, model_dir=None,
               graph_builder_class=tensor_forest.RandomForestGraphs,
               config=None, weights_name=None, keys_name=None,
               feature_engineering_fn=None, early_stopping_rounds=100):

    """Initializes a TensorForestEstimator instance.

    Args:
      params: ForestHParams object that holds random forest hyperparameters.
        These parameters will be passed into `model_fn`.
      device_assigner: An `object` instance that controls how trees get
        assigned to devices. If `None`, will use
        `tensor_forest.RandomForestDeviceAssigner`.
      model_dir: Directory to save model parameters, graph, etc. To continue
        training a previously saved model, load checkpoints saved to this
        directory into an estimator.
      graph_builder_class: An `object` instance that defines how TF graphs for
        random forest training and inference are built. By default will use
        `tensor_forest.RandomForestGraphs`.
      config: `RunConfig` object to configure the runtime settings.
      weights_name: A string defining feature column name representing
        weights. Will be multiplied by the loss of the example. Used to
        downweight or boost examples during training.
      keys_name: A string defining feature column name representing example
        keys. Used by `predict_with_keys` method.
      feature_engineering_fn: Feature engineering function. Takes features and
        labels which are the output of `input_fn` and returns features and
        labels which will be fed into the model.
      early_stopping_rounds: Allows training to terminate early if the forest is
        no longer growing. 100 by default.

    Returns:
      A `TensorForestEstimator` instance.
    """
    self.params = params.fill()
    self.graph_builder_class = graph_builder_class
    self.early_stopping_rounds = early_stopping_rounds
    self.weights_name = weights_name
    self._estimator = estimator.Estimator(
        model_fn=get_model_fn(params, graph_builder_class, device_assigner,
                              weights_name=weights_name, keys_name=keys_name),
        model_dir=model_dir,
        config=config,
        feature_engineering_fn=feature_engineering_fn) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:46,代碼來源:random_forest.py


注:本文中的tensorflow.contrib.tensor_forest.python.tensor_forest.RandomForestDeviceAssigner方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。