#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 23 11:26:04 2018"""
import tensorflow as tf
#创建图
c=tf.constant(0.0)
g=tf.Graph()
with g.as_default():c1=tf.constant(0.1)print(c1.graph)print(g)print(c.graph)

<tensorflow.python.framework.ops.Graph object at 0xb1cd345c0>
<tensorflow.python.framework.ops.Graph object at 0xb1cd345c0>
<tensorflow.python.framework.ops.Graph object at 0x10d1f6160>
从输出可以看出
print(c1.graph)
print(g)
输出为同一个计算图,
而 print(c.graph)为另一个计算图

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 23 11:26:04 2018"""
import tensorflow as tf
#创建图
c=tf.constant(0.0)
g=tf.Graph()
with g.as_default():c1=tf.constant(0.1)
g2=tf.get_default_graph()
print(g2)
tf.reset_default_graph()
g3=tf.get_default_graph()
print(g3)
print(c1.name)

<tensorflow.python.framework.ops.Graph object at 0xb19ce09b0>
<tensorflow.python.framework.ops.Graph object at 0xb19ce0e48>
Const:0
重置计算图以及获得tensor

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 23 11:26:04 2018@author: myhaspl
"""
import tensorflow as tf
#创建图
c=tf.constant(0.0)
g=tf.Graph()
with g.as_default():c1=tf.constant(0.1)
g2=tf.get_default_graph()
print(g2)
tf.reset_default_graph()
g3=tf.get_default_graph()
print(g3)
print(c1.name)
t=g.get_tensor_by_name(name="Const:0")
print(t)
a=tf.constant([[1.0,2.0]])
b=tf.constant([[1.0],[3.0]])
tensor1=tf.matmul(a,b,name="exampleop")
print(tensor1.name,tensor1)
test=g3.get_tensor_by_name("exampleop:0")
print(test)print(tensor1.op.name)
testop=g3.get_operation_by_name("exampleop")
print(testop)with tf.Session() as sess:test=sess.run(test)print(test)test=tf.get_default_graph().get_tensor_by_name("exampleop:0")print(test)
tt2=g.get_operations()
print(tt2)tt3=g.as_graph_element(c1)
print(tt3)

<tensorflow.python.framework.ops.Graph object at 0x7f8aaa8e5160>
<tensorflow.python.framework.ops.Graph object at 0x7f8a90a9a710>
Const:0
Tensor(“Const:0”, shape=(), dtype=float32)
exampleop:0 Tensor(“exampleop:0”, shape=(1, 1), dtype=float32)
Tensor(“exampleop:0”, shape=(1, 1), dtype=float32)
exampleop
name: “exampleop”
op: “MatMul”
input: “Const”
input: “Const_1”
attr {
key: “T”
value {
type: DT_FLOAT
}
}
attr {
key: “transpose_a”
value {
b: false
}
}
attr {
key: “transpose_b”
value {
b: false
}
}

2018-12-25 17:26:56.179157: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
[[7.]]
Tensor(“exampleop:0”, shape=(1, 1), dtype=float32)
[<tf.Operation ‘Const’ type=Const>]
Tensor(“Const:0”, shape=(), dtype=float32)
[

tensorflow-计算图相关推荐

  1. tensorflow计算图_简单谈谈Tensorflow的运行机制

    1 前言 由于Tensorflow采用了全新的静态图设计模式,所以其运行机制与我们脑中所熟悉的动态图有着截然不同之处.TensorFlow翻译成中文就是张量流,所以TensorFlow至少代表着两个概 ...

  2. tensorflow计算图_通过从头开始模仿其API来了解TensorFlow

    TensorFlow是一个非常强大的开源机器学习库,用于实现和部署机器学习模型.这使其非常适合研究和生产.多年来,它已成为最受欢迎的深度学习库之一. 这篇文章的目标是建立一种直觉和理解深度学习库的工作 ...

  3. tensorflow 转张量类型为float_一文看懂TensorFlow计算图

    导读:在开始使用TensorFlow之前,必须了解它背后的理念.该库很大程度上基于计算图的概念,除非了解它们是如何工作的,否则无法理解如何使用该库.本文将简要介绍计算图,并展示如何使用TensorFl ...

  4. 深度学习 tensorflow 计算图,会话,张量

    1. 计算模型---计算图: tensorflow是一个通过计算图的形式来表示计算的编程系统,每一个计算都是计算图上的一个节点,节点之间的边描述计算之间的依赖关系.所以计算过程一般分为两个步骤: 1. ...

  5. Tensorflow命名空间与计算图可视化

    Tensorflow命名空间与计算图可视化 觉得有用的话,欢迎一起讨论相互学习~ 参考文献 强烈推荐Tensorflow实战Google深度学习框架 实验平台: Tensorflow1.4.0 pyt ...

  6. TensorFlow分布式详解

    每次 TensorFlow 运算都被描述成计算图的形式,允许结构和运算操作配置所具备的自由度能够被分配到各个分布式节点上.计算图可以分成多个子图,分配给服务器集群中的不同节点. 强烈推荐读者阅读论文& ...

  7. python tensorflow教程_TensorFlow入门教程TensorFlow 基本使用T

    该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 TensorFlow入门教程 TensorFlow 基本使用 TensorFlow官方中文教程 TensorFlow 的特点: 使用图 (graph) 来 ...

  8. Tensorflow多线程输入数据处理框架(一)——队列与多线程

    参考书 <TensorFlow:实战Google深度学习框架>(第2版) 对于队列,修改队列状态的操作主要有Enqueue.EnqueueMany和Dequeue.以下程序展示了如何使用这 ...

  9. julia有 pytorch包吗_有了Julia语言,深度学习框架从此不需要计算图

    选自julialang 作者:Mike Innes 等 机器之心编译 参与:刘晓坤.思源 本文基于 NeurIPS MLSys 的一篇论文<Fashionable Modelling with ...

  10. tensorflow 转张量类型为float_TensorFlow快速入门

    TensorFlow是一个数值计算库,其中数据(Tensor,张量)在计算图中流动.数据在TensorFlow用被称为张量的n维数据表示.计算图由数据和数学操作符构成. 计算图中的节点代表数学操作符 ...

最新文章

  1. Oracle数据库常用技术
  2. Linux 中断处理浅析
  3. mysql pdo 查询一条数据,使用 PDO 关联查询 MySQL 数据
  4. AI人才大战硝烟袅袅,缺口该如何填补?
  5. dicom传图像故障
  6. 深入理解HashMap(三): 关键源码逐行分析之构造函数
  7. iis同时运行django和php,使用Django同时运行UWSGI和ASGI
  8. 【网络协议】IP协议、ARP协议、RARP协议
  9. Atitit.软件开发的几大规则,法则,与原则。。。attilax总结
  10. WinISO镜像文件使用简介
  11. win10用账户登录计算机,图文详解让你的win10系统实现微软账户自动登录-系统操作与应用 -亦是美网络...
  12. Serializer和ModelSerializer
  13. mfc动态改变clip风格_欧式古典家具风格的演变历程
  14. css3实现毛玻璃效果
  15. 阿里技术团队是如何打造的?
  16. 春节小游戏之图片分类(Pytorch模型部署)
  17. MS5611气压传感器中文资料
  18. Kafka + ELK实现日志采集
  19. 密码学-password 1
  20. 【Pandas 数据分析3-2】Pandas 数据读取与输出 - Excel

热门文章

  1. JSON.parse与eval的区别
  2. 集群(cluster)原理(转)
  3. PDF文件上载图标,与启用浏览器浏览允许后依然无法在浏览器打开PDF文件的解决方案...
  4. 解决ASP.NET中的各种乱码问题
  5. 다양한 저장매체의 속도를 측정
  6. readelf源码学习
  7. 第四章 源代码的下载和编译
  8. 孝敬父母 天经地义 |有人这么疑问?
  9. mysql定位前后端问题_Web 前后端分离的意义大吗?
  10. java正则 链接_Java正则表达式获取网址和链接文字解析