本文整理汇总了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
示例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)
示例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))
示例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)
示例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)])
示例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)
示例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))
示例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))
示例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))
示例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)
示例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)
示例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)
示例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))
示例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))