TF学习——TF之API:TensorFlow的高级机器学习API—tf.contrib.learn的简介、使用方法、案例应用之详细攻略

简介: TF学习——TF之API:TensorFlow的高级机器学习API—tf.contrib.learn的简介、使用方法、案例应用之详细攻略

tf.contrib.learn的简介




tf.contrib.learn 是 TensorFlow 提供的一个机器学习高级 API 模块,让用户可以更方便的配置、训练和评估各种各样的机器学习模型,里面内置了很多模型可以直接调用,其实,就是类似最经典的机器学习库 scikit-learn 的 API 。很多调用方法都很相同。


1、常用的模型


线性分类 tf.contrib.learn.LinearClassifier

线性回归 tf.contrib.learn.LinearRegressor

逻辑斯谛回归 tf.contrib.learn.LogisticRegressor

K-means 聚类 tf.contrib.learn.KMeansClustering

神经网络分类器 tf.contrib.learn.DNNClassifier

神经网络回归器 tf.contrib.learn.DNNRegressor

广度深度回归 tf.contrib.learn.DNNLinearCombinedRegressor

广度深度分类 tf.contrib.learn.DNNLinearCombinedClassifier

注意:该模块已被弃用,请仔细查看API说明,https://github.com/tensorflow/tensorflow/blob/r1.13/tensorflow/contrib/learn/README.md

Many canned estimators (subclasses of Estimator) have equivalents in core exposed under tf.estimator: DNNClassifier, DNNRegressor, DNNEstimator, LinearClassifier, LinearRegressor, LinearEstimator, DNNLinearCombinedClassifier,DNNLinearCombinedRegressor and DNNLinearCombinedEstimator.


To migrate to the new api, users need to take the following steps:

Replace tf.contrib.learn with tf.estimator.



tf.contrib.learn的使用方法


Modules


datasets module: Dataset utilities and synthetic/reference datasets (deprecated).

graph_actions module: High level operations on graphs (deprecated).

head module: Abstractions for the head(s) of a model (deprecated).

io module: Tools to allow different io formats (deprecated).

learn_runner module: Utilities to run and tune an Experiment (deprecated).

models module: Various high level TF models (deprecated).

monitors module: Monitors instrument the training process (deprecated).

ops module: Various TensorFlow Ops (deprecated).

preprocessing module: Preprocessing tools useful for building models (deprecated).

utils module: TensorFlow Learn Utils (deprecated).


Classes


class BaseEstimator: Abstract BaseEstimator class to train and evaluate TensorFlow models.

class DNNClassifier: A classifier for TensorFlow DNN models.

class DNNEstimator: A Estimator for TensorFlow DNN models with user specified _Head.

class DNNLinearCombinedClassifier: A classifier for TensorFlow Linear and DNN joined training models.

class DNNLinearCombinedEstimator: An estimator for TensorFlow Linear and DNN joined training models.

class DNNLinearCombinedRegressor: A regressor for TensorFlow Linear and DNN joined training models.

class DNNRegressor: A regressor for TensorFlow DNN models.

class DynamicRnnEstimator: Dynamically unrolled RNN (deprecated).

class Estimator: Estimator class is the basic TensorFlow model trainer/evaluator.

class Evaluable: Interface for objects that are evaluatable by, e.g., Experiment.

class Experiment: Experiment is a class containing all information needed to train a model.

class ExportStrategy: A class representing a type of model export.

class Head: Interface for the head/top of a model.

class InputFnOps: A return type for an input_fn (deprecated).

class KMeansClustering: An Estimator for K-Means clustering.

class LinearClassifier: Linear classifier model.

class LinearEstimator: Linear model with user specified head.

class LinearRegressor: Linear regressor model.

class MetricSpec: MetricSpec connects a model to metric functions.

class ModeKeys: Standard names for model modes (deprecated).

class ModelFnOps: Ops returned from a model_fn.

class NanLossDuringTrainingError: Unspecified run-time error.

class NotFittedError: Exception class to raise if estimator is used before fitting.

class PredictionKey: THIS CLASS IS DEPRECATED.

class ProblemType: Enum-like values for the type of problem that the model solves.

class RunConfig: This class specifies the configurations for an Estimator run.

class SKCompat: Scikit learn wrapper for TensorFlow Learn Estimator.

class SVM: Support Vector Machine (SVM) model for binary classification.

class TaskType: DEPRECATED CLASS.

class Trainable: Interface for objects that are trainable by, e.g., Experiment.


Functions


LogisticRegressor(...): Builds a logistic regression Estimator for binary classification.

binary_svm_head(...): Creates a Head for binary classification with SVMs. (deprecated)

build_parsing_serving_input_fn(...): Build an input_fn appropriate for serving, expecting fed tf.Examples. (deprecated)

evaluate(...): Evaluate a model loaded from a checkpoint. (deprecated)

extract_dask_data(...): Extract data from dask.Series or dask.DataFrame for predictors. (deprecated)

extract_dask_labels(...): Extract data from dask.Series or dask.DataFrame for labels. (deprecated)

extract_pandas_data(...): Extract data from pandas.DataFrame for predictors. (deprecated)

extract_pandas_labels(...): Extract data from pandas.DataFrame for labels. (deprecated)

extract_pandas_matrix(...): Extracts numpy matrix from pandas DataFrame. (deprecated)

infer(...): Restore graph from restore_checkpoint_path and run output_dict tensors. (deprecated)

infer_real_valued_columns_from_input(...): Creates FeatureColumn objects for inputs defined by input x. (deprecated)

infer_real_valued_columns_from_input_fn(...): Creates FeatureColumn objects for inputs defined by input_fn. (deprecated)

make_export_strategy(...): Create an ExportStrategy for use with Experiment. (deprecated)

multi_class_head(...): Creates a Head for multi class single label classification. (deprecated)

multi_head(...): Creates a MultiHead stemming from same logits/hidden layer. (deprecated)

multi_label_head(...): Creates a Head for multi label classification. (deprecated)

no_op_train_fn(...): DEPRECATED FUNCTION

poisson_regression_head(...): Creates a Head for poisson regression. (deprecated)

read_batch_examples(...): Adds operations to read, queue, batch Example protos. (deprecated)

read_batch_features(...): Adds operations to read, queue, batch and parse Example protos. (deprecated)

read_batch_record_features(...): Reads TFRecord, queues, batches and parses Example proto. (deprecated)

read_keyed_batch_examples(...): Adds operations to read, queue, batch Example protos. (deprecated)

read_keyed_batch_examples_shared_queue(...): Adds operations to read, queue, batch Example protos. (deprecated)

read_keyed_batch_features(...): Adds operations to read, queue, batch and parse Example protos. (deprecated)

read_keyed_batch_features_shared_queue(...): Adds operations to read, queue, batch and parse Exampleprotos.(deprecated)

regression_head(...): Creates a Head for linear regression. (deprecated)

run_feeds(...): See run_feeds_iter(). Returns a list instead of an iterator. (deprecated)

run_n(...): Run output_dict tensors n times, with the same feed_dict each run. (deprecated)

train(...): Train a model. (deprecated)



tf.contrib.learn的案例应用


更新……


 


相关文章
|
2月前
|
机器学习/深度学习 PyTorch TensorFlow
TensorFlow和PyTorch的实际应用比较
TensorFlow和PyTorch的实际应用比较
|
2月前
|
存储 Linux API
Linux源码阅读笔记08-进程调度API系统调用案例分析
Linux源码阅读笔记08-进程调度API系统调用案例分析
|
2月前
|
机器学习/深度学习 人工智能 自然语言处理
【机器学习】机器学习、深度学习、强化学习和迁移学习简介、相互对比、区别与联系。
机器学习、深度学习、强化学习和迁移学习都是人工智能领域的子领域,它们之间有一定的联系和区别。下面分别对这四个概念进行解析,并给出相互对比、区别与联系以及应用场景案例分析。
35 1
|
2月前
|
JSON 数据管理 关系型数据库
【Dataphin V3.9】颠覆你的数据管理体验!API数据源接入与集成优化,如何让企业轻松驾驭海量异构数据,实现数据价值最大化?全面解析、实战案例、专业指导,带你解锁数据整合新技能!
【8月更文挑战第15天】随着大数据技术的发展,企业对数据处理的需求不断增长。Dataphin V3.9 版本提供更灵活的数据源接入和高效 API 集成能力,支持 MySQL、Oracle、Hive 等多种数据源,增强 RESTful 和 SOAP API 支持,简化外部数据服务集成。例如,可轻松从 RESTful API 获取销售数据并存储分析。此外,Dataphin V3.9 还提供数据同步工具和丰富的数据治理功能,确保数据质量和一致性,助力企业最大化数据价值。
115 1
|
2月前
|
机器学习/深度学习 开发者 Python
Python 与 R 在机器学习入门中的学习曲线差异
【8月更文第6天】在机器学习领域,Python 和 R 是两种非常流行的编程语言。Python 以其简洁的语法和广泛的社区支持著称,而 R 则以其强大的统计功能和数据分析能力受到青睐。本文将探讨这两种语言在机器学习入门阶段的学习曲线差异,并通过构建一个简单的线性回归模型来比较它们的体验。
51 7
|
2月前
|
机器学习/深度学习 运维 算法
【阿里天池-医学影像报告异常检测】3 机器学习模型训练及集成学习Baseline开源
本文介绍了一个基于XGBoost、LightGBM和逻辑回归的集成学习模型,用于医学影像报告异常检测任务,并公开了达到0.83+准确率的基线代码。
42 9
|
2月前
|
API UED 开发者
如何在Uno Platform中轻松实现流畅动画效果——从基础到优化,全方位打造用户友好的动态交互体验!
【8月更文挑战第31天】在开发跨平台应用时,确保用户界面流畅且具吸引力至关重要。Uno Platform 作为多端统一的开发框架,不仅支持跨系统应用开发,还能通过优化实现流畅动画,增强用户体验。本文探讨了Uno Platform中实现流畅动画的多个方面,包括动画基础、性能优化、实践技巧及问题排查,帮助开发者掌握具体优化策略,提升应用质量与用户满意度。通过合理利用故事板、减少布局复杂性、使用硬件加速等技术,结合异步方法与预设缓存技巧,开发者能够创建美观且流畅的动画效果。
57 0
|
2月前
|
UED 存储 数据管理
深度解析 Uno Platform 离线状态处理技巧:从网络检测到本地存储同步,全方位提升跨平台应用在无网环境下的用户体验与数据管理策略
【8月更文挑战第31天】处理离线状态下的用户体验是现代应用开发的关键。本文通过在线笔记应用案例,介绍如何使用 Uno Platform 优雅地应对离线状态。首先,利用 `NetworkInformation` 类检测网络状态;其次,使用 SQLite 实现离线存储;然后,在网络恢复时同步数据;最后,通过 UI 反馈提升用户体验。
49 0
|
2月前
|
TensorFlow 算法框架/工具 异构计算
【Tensorflow 2】查看GPU是否能应用
提供了检查TensorFlow是否能应用GPU的方法。
16 2
|
2月前
|
机器学习/深度学习
【机器学习】模型融合Ensemble和集成学习Stacking的实现
文章介绍了使用mlxtend和lightgbm库中的分类器,如EnsembleVoteClassifier和StackingClassifier,以及sklearn库中的SVC、KNeighborsClassifier等进行模型集成的方法。
43 1

热门文章

最新文章

下一篇
无影云桌面