TensorFlow源代码学习–1 Session API reference

TensorFlow源代码学习–1 Session API reference学习TensorFlow源代码,先把API文档扒出来研究一下整体结构:一下是文档内容的整理,简单翻译一下

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

TensorFlow源代码学习--1 Session API reference
学习TensorFlow源代码,先把API文档扒出来研究一下整体结构: 一下是文档内容的整理,简单翻译一下
原文地址:http://www.tcvpr.com/archives/181

TensorFlow C++ Session API reference documentation

TensorFlow’s public C++ API includes only the API for executing graphs, as of version 0.5. To control the execution of a graph from C++: TensorFlow的C++ API只包含执行图(graphs)的操作,像V0.5一样,控制执行图如下:

  1. Build the computation graph using the [Python API].
  • 使用Python API建立一个图
  1. Use [tf.train.write_graph()] to write the graph to a file.
  • 使用[tf.train.write_graph()]把图写入文件

Env

[tensorflow::Env]

  • An interface used by the tensorflow implementation to access operating system functionality like the filesystem etc.Callers may wish to provide a custom Env object to get fine grain control.All Env implementations are safe for concurrent access from multiple threads without any external synchronization.
  • TensorFlow使用此接口接入操作系统功能,例如文件系统等。调用者可以提供自定义的ENV对象来得到细粒度的控制(fine grain control),ENV所有的执行对于并发多线程完全支持,不需要外部同步!

[tensorflow::RandomAccessFile]

  • A file abstraction for randomly reading the contents of a file.
  • 一个文件的抽象,为了从文件中随机读取内容

[tensorflow::WritableFile]

  • A file abstraction for sequential writing.The implementation must provide buffering since callers may append small fragments at a time to the file.
  • 一个文件的抽象,用于按照序列存储文件,此执行必须提供Buffer,因为调用者对于一个文件一次可能只增加小的片段。

[tensorflow::EnvWrapper]

  • An implementation of Env that forwards all calls to another Env .May be useful to clients who wish to override just part of the functionality of another Env .
  • ENV的一个执行,将ENV的所有调用链接到其他ENV。对于想要重载(override)其他ENV部分功能的用户,此类可能有用。

Session

[tensorflow::Session]

  • A Session instance lets a caller drive a TensorFlow graph computation.When a Session is created with a given target, a new Session object is bound to the universe of resources specified by that target. Those resources are available to this session to perform computation described in the GraphDef. After extending the session with a graph, the caller uses the Run() API to perform the computation and potentially fetch outputs as Tensors.

  • 一个Session的实例,可以调用者启动一个TensorFlow图(graph)的计算功能。当一个有目标的Session建立时,一个新的Session对象一定是所有目标(target)指定的资源的总体。那些资源对于此Session是可用的,用来执行在图中定义(GraphDef)的计算。

  • Example:

  • 例子

    //c++ tensorflow::GraphDef graph;

    // … Create or load graph into “graph”. // This example uses the default options which connects // to a local runtime.

    tensorflow::SessionOptions options; std::unique_ptrtensorflow::Session session(tensorflow::NewSession(options));

    // Create the session with this graph.

    tensorflow::Status s = session->Create(graph); if (!s.ok()) { … } // Run the graph and fetch the first output of the “output” // operation, and also run to but do not return anything // for the “update_state” operation.

    std::vectortensorflow::Tensor outputs; s = session->Run({}, {“output:0”}, {“update_state”}, &outputs); if (!s.ok()) { … } // Map the output as a flattened float tensor, and do something // with it.

    auto output_tensor = outputs[0].flat(); if (output_tensor(0) > 0.5) { … } // Close the session to release the resources associated with // this session.

    session->Close();

  • A Session allows concurrent calls to Run() , though a Session must be created / extended by a single thread.Only one thread must call Close() , and Close() must only be called after all other calls to Run() have returned.

  • Session允许多个线程执行Run,但是Session必须由一个线程创建/扩展。只有一个线程能调用Close,并且必须在其他线程中的所有Run调用完成后。

[tensorflow::SessionOptions]

  • Configuration information for a Session
  • Session的配置信息

Status

[tensorflow::Status]

  • No description
  • 状态信息,文档无描述

[tensorflow::Status::State]

  • No description
  • 状态信息,文档无描述

Tensor

[tensorflow::Tensor]

  • Represents an n-dimensional array of values.
  • 表示一个N维值的数组

[tensorflow::TensorShape]

  • No description
  • Tensor形状,文档无描述

[tensorflow::TensorShapeDim]

  • No description
  • Tensor形状维数,文档无描述

[tensorflow::TensorShapeUtils]

  • Static helper routines for TensorShape. Includes a few common predicates on a tensor shape.
  • 对于TensorShape静态辅助例子,包括一些对于tensor形状的常见限定

[tensorflow::PartialTensorShape]

  • Manages the partially known dimensions of a Tensor and their sizes.
  • 管理一个Tensor部分已知的规模以及大小

[tensorflow::PartialTensorShapeUtils]

  • Static helper routines for PartialTensorShape. Includes a few common predicates on a partially known tensor shape.
  • 对于PartialTensorShape静态辅助例子,包括一些对于部分tensor形状的常见限定

[TF_Buffer]

  • No description
  • TensorFlow的Buffer,文档无描述

Thread

[tensorflow::Thread]

  • No Description
  • 线程操作,文档无描述

[tensorflow::ThreadOptions]

  • Options to configure a Thread .Note that the options are all hints, and the underlying implementation may choose to ignore it.
  • 线程配置,注意:这些描述都是隐藏的,底层实现可以忽略
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/183592.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • traceroute基本原理_实践与认识的相关原理

    traceroute基本原理_实践与认识的相关原理*本文原创作者:ArkTeam/YSYY,转载须注明来自FreeBuf.COM一、路由追踪程序traceroute/tracertTraceroute是Linux和MacOS等系统默认提供的路由追踪小程序,Tracert是Windows系统默认提供的路由追踪小程序。二者的功能相同,都能探测数据包从源地址到目的地址经过的路由器的IP地址。Traceroute/Tracert的实现都借助了T…

    2022年9月24日
    3
  • 2014MadCon厦门分享会-笔记(下)[通俗易懂]

    2014MadCon厦门分享会-笔记(下)[通俗易懂]32《如何与百度互动,不知道这些就不要做SEO了》百度站长平台资深产品运营师曹丽丽(飞鸟)33注意百度站长平台的提醒。如果你不留电话,不留其他联系方式,出问题了,百度怎么提醒你呢?34为什么高富帅换域名时很平稳啊?注意使用以下工具:(1)高级互动工具-网站改版(需要提交相关信息,在过度一个月之后,再撤掉原来的域名)(2)抓取异常&拒绝外链(这些都要做好重定向,提前做好准备)…

    2022年5月23日
    37
  • Python之os.path

    os.path常用函数示例参考:https://www.cnblogs.com/wuxie1989/p/5623435.html

    2021年12月19日
    57
  • 计算机xp考试模块,职称计算机考试XP模块题库

    计算机xp考试模块,职称计算机考试XP模块题库一、WindowsXP的特点、启动和退出1、要求:将你的计算机转入待机状态:开始→关闭计算机→待机2、要求:重新启动你的计算机:开始→关闭计算机→重新启动3、要求:正常退出WindowsXP系统:开始→关闭计算机→关闭4、要求:切换当前用户为DCH:开始→注销→切换用户→点“DCH已登录”5、要求:对当前用户进行注销:开始→注销→注销二、Windows的界面(一)1、要求:利用“索引”查找关于…

    2022年6月2日
    35
  • 基于SwipeRefreshLayout的上拉加载控件

    基于SwipeRefreshLayout的上拉加载控件距离上一篇博客,居然已经过了大半年的时间,时间过得真快啊!CSDN最近大改版,各种用户体验也是被无数人吐槽,让人提不起任何写博客的兴趣,不过,该写的博客还是必须得写,话不多话,直接进入正题。现在项目中用列表来展示数据比比皆是,ListView和RecyclerView大家也是耳熟能详。实际项目中,后台肯定的接口肯定都是分页的,那么,分页加载也是自然而然的事,下面基于Google原生的下拉刷新控

    2022年6月25日
    27
  • Codelf 命名神器

    Codelf 命名神器对于刚入职的新手开发小白,英语水平不好的可以使用下面这款变量命名神器地址:https://unbug.github.io/codelf/

    2022年5月4日
    63

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号