126、TensorFlow Session的执行
# tf.Session.run 方法是一个执行tf.Operation或者计算tf.Tensor的一个主要的机制
# 你可以传递一个或者多个tf.Operation或者tf.Tensor对象来给tf.Session.run
# TensorFlow会执行operation操作来计算结果
# tf.Session.run需要你来指定一系列的获取,这些决定了返回值
# 这些获取可以是 tf.Operation ,一个tf.Tensor 或者一个tensor-like type 列如tf.Variable
# 这些获取决定了子的计算图必须执行的操作来产生结果
import tensorflow as tf
x = tf.constant([[37.0, -23.0], [1.0, 4.0]])
w = tf.Variable(tf.random_uniform([2, 2]))
y = tf.matmul(x, w)
output = tf.nn.softmax(y)
init_op = w.initializer
with tf.Session() as sess:
# Run the initializer on 'w'
sess.run(init_op) # Evaluate 'output' , 'sess.run(output)' will return a NumPy array containing
# the result of the computation
print(sess.run(output)) # Evaluate 'y' and 'output'
# y will only be computed once,
# and its result used both to return
# y_valu and as an input to the tf.nn.softmax()
# op . both y_val and output_val will be NumPy arrays
y_val, output_val = sess.run([y, output]) # print result
print(y_val)
print(output_val)
126、TensorFlow Session的执行的更多相关文章
- (原)tensorflow中函数执行完毕,显存不自动释放
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/7608916.html 参考网址: https://stackoverflow.com/question ...
- tensorflow session会话控制
import tensorflow as tf # create two matrixes matrix1 = tf.constant([[3,3]]) matrix2 = tf.constant([ ...
- 125、TensorFlow计算图的执行
# TensorFlow使用tf.Session类来表示客户端程序之间的链接 # 虽然一个在其他语言中相似的接口也是可以使用的,列如C++ runtime # 一个tf.Session对象提供了访问本 ...
- What is a TensorFlow Session?
Sep 26, 2016 I've seen a lot of confusion over the rules of tf.Graph and tf.Session in TensorFlow. I ...
- tensorflow session 和 graph
graph即tf.Graph(),session即tf.Session(),很多人经常将两者混淆,其实二者完全不是同一个东西. graph定义了计算方式,是一些加减乘除等运算的组合,类似于一个函数.它 ...
- 用tensorflow的Eager执行模式
一.即时执行模式 import tensorflow as tfimport tensorflow.contrib.eager as tfetfe.enable_eager_execution() a ...
- tensorflow基础架构 - 处理结构+创建一个线性回归模型+session+Variable+Placeholder
以下仅为自己的整理记录,绝大部分参考来源:莫烦Python,建议去看原博客 一.处理结构 因为TensorFlow是采用数据流图(data flow graphs)来计算, 所以首先我们得创建一个数据 ...
- Tensorflow源码解析2 -- 前后端连接的桥梁 - Session
Session概述 1. Session是TensorFlow前后端连接的桥梁.用户利用session使得client能够与master的执行引擎建立连接,并通过session.run()来触发一次计 ...
- TensorFlow源代码学习--1 Session API reference
学习TensorFlow源代码,先把API文档扒出来研究一下整体结构: 一下是文档内容的整理,简单翻译一下 原文地址:http://www.tcvpr.com/archives/181 TensorF ...
随机推荐
- Python - pycharm 代码自动补全
有很多人说是代码补全功能未打开,的确,代码补全功能确实要打开才能用,打开方法 file---->power save mode,把这个前面的√号去掉即可
- 使用Redis共享用户登录成功的信息
一.问题 比如CSDN,开源中国等等网站,用户登录后不一定什么时候就会把你T了,意思就是不一定哪天在打开网站的时候就让你重新登录.这是怎么回事呢? 再比如:如果存到将用户信息存到Redis了,不清除的 ...
- qt 删除xml某个标签下所有子标签
代码如下: QDomNodeList listFlowChart= doc.elementsByTagName("device"); QDomElement flowChart = ...
- 问题 F: 超超的自闭意思
问题 F: 超超的自闭意思 时间限制: 1 Sec 内存限制: 128 MB提交: 80 解决: 10[提交] [状态] [命题人:jsu_admin] 题目描述 质数定义为在大于1的自然数中,除 ...
- 8、前端知识点--关于Set用法的详解【ES6】
ES6提供了新的数据结构Set,它类似于数组,但是成员的值是唯一的,没有重复的值(对于基本类型来说).Set本身是一个构造函数,用来生成Set数据结构. 1.声明 let set = new Set( ...
- Scala本地安装
一.下载 https://www.scala-lang.org/download/ 这里我选择Scala2.10.4版本 二.安装 安装比较简单 和jdk类似 点击一路安装: 选择自己的路径 完成 ...
- 浅谈GC
关于Java中的GC,简单来说就是垃圾收集器自动回收生命周期结束的对象,释放内存. 那么怎样确定对象是否存活呢? 可达性分析算法 现在主流的Java虚拟机大多使用这种可达性分析算法来判断对象是否需要进 ...
- Git的基本操作命令
Git的基本命令 ## Git命令行 ### 查看配置 ```d git config user.name //查看用户名 git config user.email //查看邮箱 ``` ### 全 ...
- pgtclsh -- PostgreSQL TCLshell 客户端
SYNOPSIS pgtclsh [filename [argument...]] DESCRIPTION 描述 pgtclsh 是一个 Tcl shell 接口,用 PostgreSQL 数据库访问 ...
- Java虚拟机——类加载机制
转自:http://blog.csdn.net/ns_code/article/details/17881581 类加载过程 类从被加载到虚拟机内存中开始,到卸载出内存为止,它的整个生命周期包括:加载 ...