本文整理汇总了Python中tensorflow.contrib.learn.python.learn.datasets.base.load_iris方法的典型用法代码示例。如果您正苦于以下问题:Python base.load_iris方法的具体用法?Python base.load_iris怎么用?Python base.load_iris使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.contrib.learn.python.learn.datasets.base
的用法示例。
在下文中一共展示了base.load_iris方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testClassification
# 需要导入模块: from tensorflow.contrib.learn.python.learn.datasets import base [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.datasets.base import load_iris [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)
示例2: iris_input_fn
# 需要导入模块: from tensorflow.contrib.learn.python.learn.datasets import base [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.datasets.base import load_iris [as 别名]
def iris_input_fn():
iris = base.load_iris()
features = tf.reshape(tf.constant(iris.data), [-1, _IRIS_INPUT_DIM])
labels = tf.reshape(tf.constant(iris.target), [-1])
return features, labels
示例3: prepare_iris_data_for_logistic_regression
# 需要导入模块: from tensorflow.contrib.learn.python.learn.datasets import base [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.datasets.base import load_iris [as 别名]
def prepare_iris_data_for_logistic_regression():
# Converts iris data to a logistic regression problem.
iris = base.load_iris()
ids = np.where((iris.target == 0) | (iris.target == 1))
return base.Dataset(data=iris.data[ids], target=iris.target[ids])
示例4: iris_input_multiclass_fn
# 需要导入模块: from tensorflow.contrib.learn.python.learn.datasets import base [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.datasets.base import load_iris [as 别名]
def iris_input_multiclass_fn():
iris = base.load_iris()
return {
'feature': constant_op.constant(
iris.data, dtype=dtypes.float32)
}, constant_op.constant(
iris.target, shape=(150, 1), dtype=dtypes.int32)
示例5: testClassificationTrainingLoss
# 需要导入模块: from tensorflow.contrib.learn.python.learn.datasets import base [as 别名]
# 或者: from tensorflow.contrib.learn.python.learn.datasets.base import load_iris [as 别名]
def testClassificationTrainingLoss(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)
classifier = random_forest.TensorForestEstimator(
hparams, graph_builder_class=(tensor_forest.TrainingLossForest))
iris = base.load_iris()
data = iris.data.astype(np.float32)
labels = iris.target.astype(np.float32)
monitors = [random_forest.TensorForestLossHook(10)]
classifier.fit(x=data, y=labels, steps=100, monitors=monitors)
classifier.evaluate(x=data, y=labels, steps=10)