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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • java应用被阻止_怎样解决运行java提示应用程序已安全设置被阻止[通俗易懂]

    java应用被阻止_怎样解决运行java提示应用程序已安全设置被阻止[通俗易懂]Win7系统运行java时出现提示应用程序已安全设置被阻止,这样就导致运行java失败,那么怎样解决运行java提示应用程序已安全设置被阻止呢?下面跟着学习啦小编来一起了解下吧。解决运行java提示应用程序已安全设置被阻止方法1、点击:开始-控制面板,选择查看方式为:大图标或小图标;2、双击java,选择“安全”,把“安全级别”降至“中”,点击“确定”;3、重启浏览器,运行java,在弹出的对话框…

    2022年7月7日
    17
  • MySQL和SQLyog安装配置教程

    MySQL和SQLyog安装配置教程文章目录1.MySQL和配套SQLyog压缩包2.MySQL的安装配置3.SQLyog(小海豚)安装4.最后成功样子5.前期练习可能会需要的脚本需要的可以下载:1.MySQL和配套SQLyog压缩包 百度网盘资源链接:链接:https://pan.baidu.com/s/15r2rmmfzFV8oB5DgdbgwiQ 提取码:3s5u2.MySQL的安装配置可参考文章1.解压压缩包后:复制bin文件的路径2.以管理员身份打开命令提示符进入刚复制的bin文件目录然后按步骤安装MyS

    2022年5月28日
    71
  • Android Activity为什么要细化出onCreate、onStart、onResume、onPause、onStop、onDesdroy这么多方法让应用去重载?

    Android Activity为什么要细化出onCreate、onStart、onResume、onPause、onStop、onDesdroy这么多方法让应用去重载?最近在研究Activity的启动流程,老罗的blog在看,也找了其它资料学习,也跟过Android4.3的源码,在跟代码的过程中,突然想到下面的这个问题:  AndroidActivity为什么要细化出onCreate、onStart、onResume、onPause、onStop、onDesdroy这么多方法让应用去重载?网上太多根据Android开发规范翻译转载的内容,都不是我想要的答案,那就自己分析下

    2022年5月5日
    33
  • linux history命令常用方法

    linux history命令常用方法c清空内存中命令历史-d#删除指定的历史命令,比如history-d100,就是删除第100个命令历史history+nn代表行例如history500查看最近500行命令历史记录

    2022年7月16日
    17
  • 什么是粘包?_网络粘包

    什么是粘包?_网络粘包TCP/IP协议簇建立了互联网中通信协议的概念模型,该协议簇中的两个主要协议就是TCP和IP协议。TCP/IP协议簇中的TCP协议能够保证数据段(Segment)的可靠性和顺序,有了可靠的传输层协议之后,应用层协议就可以直接使用TCP协议传输数据,不在需要关心数据段的丢失和重复问题。图1-TCP协议与应用层协议IP协议解决了数据包(Packet)的路由和传输,上层的TCP协议不再关注路由和寻址,那么TCP协议解决的是传输的可靠性和顺序问题,上层不需要.

    2022年8月11日
    4
  • 四种方法求最长回文子串

    四种方法求最长回文子串所谓回文串,就是正着读和倒着读结果都一样的回文字符串。比如:a,aba,abccba都是回文串,ab,abb,abca都不是回文串。一、暴力法最容易想到的就是暴力破解,求出每一个子串,之后判断是不是回文,找到最长的那个。求每一个子串时间复杂度O(N^2),判断子串是不是回文O(N),两者是相乘关系,所以时间复杂度为O(N^3)。stringlongestPali…

    2022年6月5日
    48

发表回复

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

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