当前位置: 首页>>代码示例>>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;未经允许,请勿转载。