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的案例应用


更新……


 


相关文章
|
供应链 搜索推荐 数据挖掘
探秘京东 API 接口的神奇应用场景
京东API如同数字钥匙,助力商家实现商品、库存、订单等多平台高效同步,提升效率超80%。支持物流实时追踪,增强用户满意度;赋能精准营销与数据分析,决策准确率提升20%以上,全面优化电商运营。
|
人工智能 自然语言处理 机器人
使用 API 编程开发扣子应用
扣子(Coze)应用支持通过 API 编程,将 AI 聊天、内容生成、工作流自动化等功能集成至自有系统。主要 API 包括 Bot API(用于消息交互与会话管理)及插件与知识库 API(扩展功能与数据管理)。开发流程包括创建应用、获取密钥、调用 API 并处理响应,支持 Python 等语言。建议加强错误处理、密钥安全与会话管理,提升集成灵活性与应用扩展性。
3558 0
|
监控 供应链 搜索推荐
电商数据开发实践:深度剖析1688商品详情 API 的技术与应用
在电商数字化转型中,数据获取效率与准确性至关重要。本文介绍了一款高效商品详情API,具备全维度数据采集、价格库存管理、多媒体资源获取等功能,结合实际案例探讨其在电商开发中的应用价值与优势。
|
人工智能 供应链 安全
未来电商趋势:API技术在智能供应链中的应用
随着电商蓬勃发展,供应链管理正借助API技术实现智能化升级。本文解析API作为电商生态“粘合剂”的作用,探讨其在库存管理、物流协同和风险预测中的关键应用,以及对AI融合、区块链安全和实时生态的推动。API不仅提升效率与用户体验,更重塑电商未来格局,成为企业竞争的核心优势。拥抱API集成,将是应对市场复杂性的关键策略。
|
存储 供应链 API
区块链技术在电商API中的应用:保障数据安全与交易透明
区块链技术在电商API中的应用,为数据安全与交易透明提供了新方案。通过数据加密、分布式存储、智能合约管理、商品溯源及实时结算等功能,有效提升电商数据安全性与交易可信度。然而,技术成熟度、隐私保护和监管合规等挑战仍需克服。未来,随着物联网、大数据等技术融合及政策支持,区块链将在电商领域发挥更大潜力,推动行业智能化发展。
|
API 定位技术 调度
实现精准定位的—坐标系经纬度转换API技术说明和行业应用
在地图服务、物流调度等应用中,多源地理位置数据因采用不同坐标系(如WGS84、GCJ02、BD09)需统一转换,以避免位置偏移影响路径规划与分析精度。本文介绍坐标转换背景、技术方案及Python调用示例,强调其在智慧交通与物流系统中的重要性。
1263 0
|
Ubuntu API C++
C++标准库、Windows API及Ubuntu API的综合应用
总之,C++标准库、Windows API和Ubuntu API的综合应用是一项挑战性较大的任务,需要开发者具备跨平台编程的深入知识和丰富经验。通过合理的架构设计和有效的工具选择,可以在不同的操作系统平台上高效地开发和部署应用程序。
527 11
|
存储 机器学习/深度学习 API
Android API Level 到底是什么?和安卓什么关系?应用发布如何知道自己的版本?优雅草卓伊凡
Android API Level 到底是什么?和安卓什么关系?应用发布如何知道自己的版本?优雅草卓伊凡
2185 31
Android API Level 到底是什么?和安卓什么关系?应用发布如何知道自己的版本?优雅草卓伊凡
|
人工智能 数据可视化 测试技术
AI 时代 API 自动化测试实战:Postman 断言的核心技巧与实战应用
AI 时代 API 自动化测试实战:Postman 断言的核心技巧与实战应用
1602 11
|
安全 API 数据安全/隐私保护
【Azure 环境】Microsoft Graph API实现对Entra ID中应用生成密码的时间天数
本文介绍如何通过 Azure 的 App Management Policy 限制用户在创建 AAD 应用程序的 Client Secret 时设置最长 90 天的有效期。通过 Microsoft Graph API 配置 defaultAppManagementPolicy,可有效控制密码凭据的生命周期,增强安全管理。
345 4

热门文章

最新文章