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


Python tensor_forest.ForestHParams方法代碼示例

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


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

示例1: setUp

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def setUp(self):
    self.input_data = [[-1., 0.], [-1., 2.],
                       [1., 0.], [1., -2.]]
    self.input_labels = [0., 1., 2., 3.]
    self.tree = [[1, 0], [-1, 0], [-1, 0]]
    self.tree_weights = [[1.0, 0.0], [1.0, 0.0], [1.0, 0.0]]
    self.tree_thresholds = [0., 0., 0.]

    self.ops = training_ops.Load()

    self.params = tensor_forest.ForestHParams(
        num_features=2,
        hybrid_tree_depth=2,
        base_random_seed=10,
        feature_bagging_fraction=1.0,
        regularization_strength=0.01,
        regularization="",
        weight_init_mean=0.0,
        weight_init_std=0.1)
    self.params.num_nodes = 2**self.params.hybrid_tree_depth - 1
    self.params.num_leaves = 2**(self.params.hybrid_tree_depth - 1)
    self.params.num_features_per_node = (
        self.params.feature_bagging_fraction * self.params.num_features)
    self.params.regression = False 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:26,代碼來源:k_feature_routing_function_op_test.py

示例2: setUp

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def setUp(self):
    self.params = tensor_forest.ForestHParams(
        num_classes=2,
        num_features=31,
        layer_size=11,
        num_layers=13,
        num_trees=17,
        connection_probability=0.1,
        hybrid_tree_depth=4,
        regularization_strength=0.01,
        learning_rate=0.01,
        regularization="",
        weight_init_mean=0.0,
        weight_init_std=0.1)
    self.params.regression = False
    self.params.num_nodes = 2**self.params.hybrid_tree_depth - 1
    self.params.num_leaves = 2**(self.params.hybrid_tree_depth - 1) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:19,代碼來源:decisions_to_data_then_nn_test.py

示例3: testConstructionPollution

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def testConstructionPollution(self):
    """Ensure that graph building doesn't modify the params in a bad way."""
    # pylint: disable=W0612
    data = [[random.uniform(-1, 1) for i in range(self.params.num_features)]
            for _ in range(100)]

    self.assertTrue(isinstance(self.params, tensor_forest.ForestHParams))
    self.assertFalse(
        isinstance(self.params.num_trees, tensor_forest.ForestHParams))

    with variable_scope.variable_scope(
        "DecisionsToDataThenNNTest_testContructionPollution"):
      graph_builder = decisions_to_data_then_nn.DecisionsToDataThenNN(
          self.params)

      self.assertTrue(isinstance(self.params, tensor_forest.ForestHParams))
      self.assertFalse(
          isinstance(self.params.num_trees, tensor_forest.ForestHParams)) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:20,代碼來源:decisions_to_data_then_nn_test.py

示例4: setUp

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def setUp(self):
    self.params = tensor_forest.ForestHParams(
        num_classes=2,
        num_features=31,
        layer_size=11,
        num_layers=13,
        num_trees=3,
        connection_probability=0.1,
        hybrid_tree_depth=4,
        regularization_strength=0.01,
        regularization="",
        base_random_seed=10,
        feature_bagging_fraction=1.0,
        learning_rate=0.01,
        weight_init_mean=0.0,
        weight_init_std=0.1)
    self.params.regression = False
    self.params.num_nodes = 2**self.params.hybrid_tree_depth - 1
    self.params.num_leaves = 2**(self.params.hybrid_tree_depth - 1)

    self.params.num_features_per_node = (self.params.feature_bagging_fraction *
                                         self.params.num_features) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:24,代碼來源:forest_to_data_then_nn_test.py

示例5: setUp

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def setUp(self):
    self.params = tensor_forest.ForestHParams(
        num_classes=2,
        num_features=31,
        layer_size=11,
        num_layers=13,
        num_trees=17,
        connection_probability=0.1,
        hybrid_tree_depth=4,
        regularization_strength=0.01,
        regularization="",
        base_random_seed=10,
        hybrid_feature_bagging_fraction=1.0,
        learning_rate=0.01,
        weight_init_mean=0.0,
        weight_init_std=0.1)
    self.params.regression = False
    self.params.num_nodes = 2**self.params.hybrid_tree_depth - 1
    self.params.num_leaves = 2**(self.params.hybrid_tree_depth - 1)
    self.params.num_features_per_node = (self.params.feature_bagging_fraction *
                                         self.params.num_features) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:23,代碼來源:k_feature_decisions_to_data_then_nn_test.py

示例6: setUp

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def setUp(self):
    self.params = tensor_forest.ForestHParams(
        num_classes=2,
        num_features=31,
        layer_size=11,
        num_layers=13,
        num_trees=17,
        connection_probability=0.1,
        hybrid_tree_depth=4,
        regularization_strength=0.01,
        regularization="",
        learning_rate=0.01,
        weight_init_mean=0.0,
        weight_init_std=0.1)
    self.params.regression = False
    self.params.num_nodes = 2**self.params.hybrid_tree_depth - 1
    self.params.num_leaves = 2**(self.params.hybrid_tree_depth - 1)

    # pylint: disable=W0612
    self.input_data = constant_op.constant(
        [[random.uniform(-1, 1) for i in range(self.params.num_features)]
         for _ in range(100)]) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:24,代碼來源:decisions_to_data_test.py

示例7: testForestHParams

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def testForestHParams(self):
    hparams = tensor_forest.ForestHParams(
        num_classes=2,
        num_trees=100,
        max_nodes=1000,
        split_after_samples=25,
        num_features=60).fill()
    self.assertEquals(2, hparams.num_classes)
    self.assertEquals(3, hparams.num_output_columns)
    self.assertEquals(60, hparams.num_splits_to_consider)
    # Don't have more fertile nodes than max # leaves, which is 500.
    self.assertEquals(500, hparams.max_fertile_nodes)
    # Default value of valid_leaf_threshold
    self.assertEquals(1, hparams.valid_leaf_threshold)
    # floor(60 / 25) = 2
    self.assertEquals(2, hparams.split_initializations_per_input)
    self.assertEquals(0, hparams.base_random_seed) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:19,代碼來源:tensor_forest_test.py

示例8: testTrainingConstructionRegression

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def testTrainingConstructionRegression(self):
    input_data = [[-1., 0.], [-1., 2.],  # node 1
                  [1., 0.], [1., -2.]]  # node 2
    input_labels = [0, 1, 2, 3]

    params = tensor_forest.ForestHParams(
        num_classes=4,
        num_features=2,
        num_trees=10,
        max_nodes=1000,
        split_after_samples=25,
        regression=True).fill()

    graph_builder = tensor_forest.RandomForestGraphs(params)
    graph = graph_builder.training_graph(input_data, input_labels)
    self.assertTrue(isinstance(graph, ops.Operation)) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:18,代碼來源:tensor_forest_test.py

示例9: testTrainingConstructionClassificationSparse

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def testTrainingConstructionClassificationSparse(self):
    input_data = sparse_tensor.SparseTensor(
        indices=[[0, 0], [0, 3], [1, 0], [1, 7], [2, 1], [3, 9]],
        values=[-1.0, 0.0, -1., 2., 1., -2.0],
        dense_shape=[4, 10])
    input_labels = [0, 1, 2, 3]

    params = tensor_forest.ForestHParams(
        num_classes=4,
        num_features=10,
        num_trees=10,
        max_nodes=1000,
        split_after_samples=25).fill()

    graph_builder = tensor_forest.RandomForestGraphs(params)
    graph = graph_builder.training_graph(input_data, input_labels)
    self.assertTrue(isinstance(graph, ops.Operation)) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:19,代碼來源:tensor_forest_test.py

示例10: testInferenceConstructionSparse

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def testInferenceConstructionSparse(self):
    input_data = sparse_tensor.SparseTensor(
        indices=[[0, 0], [0, 3],
                 [1, 0], [1, 7],
                 [2, 1],
                 [3, 9]],
        values=[-1.0, 0.0,
                -1., 2.,
                1.,
                -2.0],
        dense_shape=[4, 10])

    params = tensor_forest.ForestHParams(
        num_classes=4,
        num_features=10,
        num_trees=10,
        max_nodes=1000,
        split_after_samples=25).fill()

    graph_builder = tensor_forest.RandomForestGraphs(params)
    graph = graph_builder.inference_graph(input_data)
    self.assertTrue(isinstance(graph, ops.Tensor)) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:24,代碼來源:tensor_forest_test.py

示例11: testClassification

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def testClassification(self):
    """Tests multi-class classification using matrix data as input."""
    hparams = tensor_forest.ForestHParams(
        num_trees=3,
        max_nodes=1000,
        num_classes=3,
        num_features=4,
        split_after_samples=20)
    classifier = random_forest.TensorForestEstimator(hparams.fill())

    iris = base.load_iris()
    data = iris.data.astype(np.float32)
    labels = iris.target.astype(np.float32)

    classifier.fit(x=data, y=labels, steps=100, batch_size=50)
    classifier.evaluate(x=data, y=labels, steps=10) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:18,代碼來源:random_forest_test.py

示例12: setUp

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def setUp(self):
    self.params = tensor_forest.ForestHParams(
        num_classes=2,
        num_features=31,
        layer_size=11,
        num_layers=13,
        num_trees=3,
        connection_probability=0.1,
        hybrid_tree_depth=4,
        regularization_strength=0.01,
        regularization="",
        base_random_seed=10,
        feature_bagging_fraction=1.0,
        learning_rate=0.01,
        weight_init_mean=0.0,
        weight_init_std=0.1)
    self.params.regression = False
    self.params.num_nodes = 2**self.params.hybrid_tree_depth - 1
    self.params.num_leaves = 2**(self.params.hybrid_tree_depth - 1)

    self.params.num_features_per_node = (
        self.params.feature_bagging_fraction * self.params.num_features) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:24,代碼來源:forest_to_data_then_nn_test.py

示例13: setUp

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def setUp(self):
    self.params = tensor_forest.ForestHParams(
        num_classes=2,
        num_features=31,
        layer_size=11,
        num_layers=13,
        num_trees=17,
        connection_probability=0.1,
        hybrid_tree_depth=4,
        regularization_strength=0.01,
        regularization="",
        base_random_seed=10,
        hybrid_feature_bagging_fraction=1.0,
        learning_rate=0.01,
        weight_init_mean=0.0,
        weight_init_std=0.1)
    self.params.regression = False
    self.params.num_nodes = 2**self.params.hybrid_tree_depth - 1
    self.params.num_leaves = 2**(self.params.hybrid_tree_depth - 1)
    self.params.num_features_per_node = (
        self.params.feature_bagging_fraction * self.params.num_features) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:23,代碼來源:k_feature_decisions_to_data_then_nn_test.py

示例14: testTrainingConstructionClassificationSparse

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def testTrainingConstructionClassificationSparse(self):
    input_data = tf.SparseTensor(
        indices=[[0, 0], [0, 3],
                 [1, 0], [1, 7],
                 [2, 1],
                 [3, 9]],
        values=[-1.0, 0.0,
                -1., 2.,
                1.,
                -2.0],
        shape=[4, 10])
    input_labels = [0, 1, 2, 3]

    params = tensor_forest.ForestHParams(
        num_classes=4, num_features=10, num_trees=10, max_nodes=1000,
        split_after_samples=25).fill()

    graph_builder = tensor_forest.RandomForestGraphs(params)
    graph = graph_builder.training_graph(input_data, input_labels)
    self.assertTrue(isinstance(graph, tf.Operation)) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:22,代碼來源:tensor_forest_test.py

示例15: testInferenceConstructionSparse

# 需要導入模塊: from tensorflow.contrib.tensor_forest.python import tensor_forest [as 別名]
# 或者: from tensorflow.contrib.tensor_forest.python.tensor_forest import ForestHParams [as 別名]
def testInferenceConstructionSparse(self):
    input_data = tf.SparseTensor(
        indices=[[0, 0], [0, 3],
                 [1, 0], [1, 7],
                 [2, 1],
                 [3, 9]],
        values=[-1.0, 0.0,
                -1., 2.,
                1.,
                -2.0],
        shape=[4, 10])

    params = tensor_forest.ForestHParams(
        num_classes=4, num_features=10, num_trees=10, max_nodes=1000,
        split_after_samples=25).fill()

    graph_builder = tensor_forest.RandomForestGraphs(params)
    graph = graph_builder.inference_graph(input_data)
    self.assertTrue(isinstance(graph, tf.Tensor)) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:21,代碼來源:tensor_forest_test.py


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