学习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.
  • 线程配置,注意:这些描述都是隐藏的,底层实现可以忽略

TensorFlow源代码学习--1 Session API reference的更多相关文章

  1. 学习笔记TF050:TensorFlow源代码解析

    TensorFlow目录结构. ACKNOWLEDGMENTS #TensorFlow版本声明 ADOPTERS.md #使用TensorFlow的人员或组织列表 AUTHORS #TensorFlo ...

  2. ArcGIS API Reference & Flex API samples学习进度备忘

    书签:跳过:另外跳过的内容有待跟进 __________________学习资源: 1.http://help.arcgis.com/en/webapi/flex/apiref/index.html ...

  3. 学习参考《TensorFlow深度学习》高清中文版PDF+英文版PDF+源代码

    我们知道,TensorFlow是比较流行的深度学习框架,除了看手册文档外,推荐大家看看<Tensorflow深度学习>,共分5方面内容:基础知识.关键模块.算法模型.内核揭秘.生态发展.前 ...

  4. lua源代码学习(一)lua的c api外围实现

    工作后,整个人已经比較松懈了.尽管一直在看lua的源代码.可是一直是比較零碎的时间,没有系统的整理,所以还是收获不多.由于近期工作也不是非常忙了,就想整理下lua的源代码学习的笔记.加深下印象,并分享 ...

  5. (转) TensorFlow深度学习,一篇文章就够了

    TensorFlow深度学习,一篇文章就够了 2016/09/22 · IT技术 · TensorFlow, 深度学习 分享到:6   原文出处: 我爱计算机 (@tobe迪豪 )    作者: 陈迪 ...

  6. TensorFlow深度学习,一篇文章就够了

    http://blog.jobbole.com/105602/ 作者: 陈迪豪,就职小米科技,深度学习工程师,TensorFlow代码提交者. TensorFlow深度学习框架 Google不仅是大数 ...

  7. 问题集录--TensorFlow深度学习

    TensorFlow深度学习框架 Google不仅是大数据和云计算的领导者,在机器学习和深度学习上也有很好的实践和积累,在2015年年底开源了内部使用的深度学习框架TensorFlow. 与Caffe ...

  8. 读Flask源代码学习Python--config原理

    读Flask源代码学习Python--config原理 个人学习笔记,水平有限.如果理解错误的地方,请大家指出来,谢谢!第一次写文章,发现好累--!. 起因   莫名其妙在第一份工作中使用了从来没有接 ...

  9. 没有博士学位,照样玩转TensorFlow深度学习

    教程 | 没有博士学位,照样玩转TensorFlow深度学习 机器之心2017-01-24 12:32:22 程序设计 谷歌 操作系统 阅读(362)评论(0) 选自Codelabs 机器之心编译 参 ...

随机推荐

  1. 《深入实践C++模板编程》之六——标准库中的容器

    1.容器的基本要求 a.并非所有的数据都可以放进容器当中.各种容器模板对所存数据类型都有一个基本要求——可复制构造.将数据放进容器的过程就是通过数据的复制构造函数在容器内创建数据的一个副本的过程. b ...

  2. 【原创】大数据基础之Kudu(4)spark读写kudu

    spark2.4.3+kudu1.9 1 批量读 val df = spark.read.format("kudu") .options(Map("kudu.master ...

  3. 【Opencv 源码剖析】 一、 create函数

    1. inline Mat::Mat(int _rows, int _cols, int _type) : size(&rows) { initEmpty();//将data.cols.row ...

  4. 记一次配置阿里云ECS GPU计算型gn5实例

    基础配置 CPU: Intel(R) Xeon(R) CPU E5-2682 v4 @ 2.50GHz * 16 MEM: 120 GiB GPU: NVIDIA P100 * 2 OS: Ubunt ...

  5. java后台读取配置文件

    前几天开发时遇到一个问题,在后台读取配置文件的时候无法读取属性值,于是上网查了查,现在在这分享给大家: 先附上代码吧: package com.shafei.util; import java.io. ...

  6. electron-vue在npm run build时报错 ⨯ cannot execute cause=fork/exec C:\Users\801\AppData\Local\electron-builder\Cache\winCodeSign\winCodeSign-2.5.0\rcedit-ia32.exe: Access is denied.

    问题描述 在electron-vue执行npm run build时报错,错误如下: ⨯ cannot execute cause=fork/exec C:\Users\801\AppData\Loc ...

  7. vue学习(5)-评论功能(利用父组件的方法)

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. JavaJDBC【六、连接池】

    背景 1.连接是一种重要资源 2.频繁连接数据库会增加数据库压力 常用连接池 dbcp 1.导入jar包(官网下载) commons-dbcp.jar commons-pool.jar commons ...

  9. 【大数据】初识Hadoop

    因为项目日志体量较大,每天有4-7T的日志量,传统的sqlserver已经不能满足,所以现在需要使用到大数据的相关工具进行记录和使用. 虽然公共项目提供了组件和解决方案,但是对于一些名词.概念还是有必 ...

  10. innodb存储引擎之内存

    1.innoDB存储引擎体系架构 如上图所示,innoDB存储是基于磁盘存储的,并且其中的记录以页的方式进行管理,但为什么要引入一个内存池呢? 其目的就是为了协调CUP速度与磁盘速度的鸿沟,基于磁盘的 ...