当前位置: 首页 > news >正文

蒙阴哪有做淘宝网站的好看的网站设计

蒙阴哪有做淘宝网站的,好看的网站设计,为什么我有的网站打不开,做软件开发的网站有哪些一、什么是图结构 1、图包含了一组tf.Operation代表的计算单元对象和tf.Tensor代表的计算单元之间流动的数据 图结构:数据(Tensor) 操作(Operation) 二、图相关操作 1、默认图 通常TensorFlow会默认帮我们创建一张图 查看默认图的两种方法: &#x…

一、什么是图结构

1、图包含了一组tf.Operation代表的计算单元对象和tf.Tensor代表的计算单元之间流动的数据
图结构:数据(Tensor) + 操作(Operation)

二、图相关操作

1、默认图
通常TensorFlow会默认帮我们创建一张图

查看默认图的两种方法:
(1)通过调用tf.compat.v1.get_default_graph()访问,要将操作添加到默认图形中,直接创建OP即可
(2)op、sess都含有graph属性,默认都在一张图中
注:2.x版本(使用默认图)不支持调用属性,会报错“AttributeError: Tensor.graph is meaningless when eager execution is enabled.”

import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import tensorflow as tfdef tensorflow_demo():"""TensorFlow的基本结构"""# TensorFlow实现加减法运算a_t = tf.constant(2)b_t = tf.constant(3)c_t = a_t + b_tprint("TensorFlow加法运算结果:\n", c_t)print(c_t.numpy())# 2.0版本不需要开启会话,已经没有会话模块了return Nonedef graph_demo():"""图的演示"""# TensorFlow实现加减法运算a_t = tf.constant(2)b_t = tf.constant(3)c_t = a_t + b_tprint("TensorFlow加法运算结果:\n", c_t)print(c_t.numpy())# 查看默认图# 方法1:调用方法default_g = tf.compat.v1.get_default_graph()print("default_g:\n", default_g)# 方法2:查看属性# print("a_t的图属性:\n", a_t.graph)# print("c_t的图属性:\n", c_t.graph)return Noneif __name__ == "__main__":# 代码1:TensorFlow的基本结构# tensorflow_demo()# 代码2:图的演示graph_demo()
python3 day01_deeplearning.pyTensorFlow加法运算结果:tf.Tensor(5, shape=(), dtype=int32)
5
default_g:<tensorflow.python.framework.ops.Graph object at 0x7f27651b5be0>

2、创建图
(1)可以通过tf.Graph()自定义创建图
(2)如果要在这张图中创建OP,典型用法是使用tf.Graph.as_default()上下文管理器

import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
import tensorflow as tfdef tensorflow_demo():"""TensorFlow的基本结构"""# TensorFlow实现加减法运算a_t = tf.constant(2)b_t = tf.constant(3)c_t = a_t + b_tprint("TensorFlow加法运算结果:\n", c_t)print(c_t.numpy())# 2.0版本不需要开启会话,已经没有会话模块了return Nonedef graph_demo():"""图的演示"""# TensorFlow实现加减法运算a_t = tf.constant(2)b_t = tf.constant(3)c_t = a_t + b_tprint("TensorFlow加法运算结果:\n", c_t)print(c_t.numpy())# 查看默认图# 方法1:调用方法default_g = tf.compat.v1.get_default_graph()print("default_g:\n", default_g)# 方法2:查看属性# print("a_t的图属性:\n", a_t.graph)# print("c_t的图属性:\n", c_t.graph)# 自定义图new_g = tf.Graph()# 在自己的图中定义数据和操作with new_g.as_default():a_new = tf.constant(20)b_new = tf.constant(30)c_new = a_new + b_newprint("c_new:\n", c_new)print("a_new的图属性:\n", a_new.graph)print("b_new的图属性:\n", b_new.graph)# 开启new_g的会话with tf.compat.v1.Session(graph=new_g) as sess:c_new_value = sess.run(c_new)print("c_new_value:\n", c_new_value)print("我们自己创建的图为:\n", sess.graph)return Noneif __name__ == "__main__":# 代码1:TensorFlow的基本结构# tensorflow_demo()# 代码2:图的演示graph_demo()
python3 day01_deeplearning.pyTensorFlow加法运算结果:tf.Tensor(5, shape=(), dtype=int32)
5
default_g:<tensorflow.python.framework.ops.Graph object at 0x7f19806c4d68>
c_new:Tensor("add:0", shape=(), dtype=int32)
a_new的图属性:<tensorflow.python.framework.ops.Graph object at 0x7f19809f5748>
b_new的图属性:<tensorflow.python.framework.ops.Graph object at 0x7f19809f5748>
c_new_value:50
我们自己创建的图为:<tensorflow.python.framework.ops.Graph object at 0x7f19809f5748>

说明:
(1)默认图执行结果是tf.Tensor(5, shape=(), dtype=int32)
(2)自定义图执行结果是Tensor("add:0", shape=(), dtype=int32)
(3)自定义图没有即时执行,需要开启Session指定图来执行
(4)可以看到默认图地址为0x7f19806c4d68,自定义图地址为0x7f19809f5748
 

http://www.zhongyajixie.com/news/39583.html

相关文章:

  • 天津多媒体设计公司搜索引擎优化推广
  • 网站聚合优化河南郑州网站推广优化外包
  • ppt做的模板下载网站有哪些内容微信营销的优势
  • wordpress怎么做两个语言网站查域名
  • 有好的学网站建设的书吗百度关键词怎么刷上去
  • 如何制作网站详细教程培训心得体会2000字
  • 做视频点播网站的要求汕头seo外包机构
  • 返利网站开发文档专业seo站长工具全面查询网站
  • 网站推广外包公司郑州企业网络推广外包
  • 企业官方网站认证网络电商推广方案
  • 网络广告案例以及分析大连seo网站推广
  • 网站如何加入广告联盟互联网销售
  • ps网站首页直线教程seo搜索引擎优化方案
  • 自己做网站做那种类型宁德市疫情最新消息
  • 豪华跑车网站建设百度排名服务
  • 太原智能化营销网站制作公司项目外包平台
  • 创建公司主页长沙seo服务哪个公司好
  • wordpress for sae 插件信息流优化师发展前景
  • 邯郸网站优化怎么做网络推广页面
  • 热门国际新闻关键词推广优化
  • 营销型网站设计流程中国进入一级战备状态了吗
  • 做网站的公司哪家靠谱腾讯企业邮箱登录入口
  • 做动漫网站的意义2021热门网络营销案例
  • 网站建设 有限公司网页百度
  • 邢台做网站邮箱沧州百度推广公司
  • 云服务器网站文件夹西安网站建设公司电话
  • 个人网站作品欣赏长沙做引流推广的公司
  • 网站 虚拟主机媒体宣传推广方案
  • 西安做网站的公司有哪些网络推广好做吗
  • 做网站多少钱西宁君博专注seo快速排名软件首页