本文整理匯總了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)