1. import tensorflow as tf
  2. with tf.name_scope("hello") as name_scope:
  3. arr1 = tf.get_variable("arr1", shape=[2,10],dtype=tf.float32)
  4. print (name_scope)
  5. print (arr1.name)
  6. print ("scope_name:%s " % tf.get_variable_scope().original_name_scope)

运行后的结果如下:

hello/
arr1:0
scope_name:

  1. import tensorflow as tf
  2. with tf.name_scope('hidden') as scope:
  3. a = tf.constant(5, name='alpha')
  4. W = tf.Variable(tf.random_uniform([1, 2], -1.0, 1.0), name='weights')
  5. b = tf.Variable(tf.zeros([1]), name='biases')
  6. print (a.name)
  7. print (W.name)
  8. print (b.name)

运行的结果:

hidden/alpha:0
hidden/weights:0
hidden/biases:0

红色字体要强调的部分所以把字体改成了红色,理解name_scope 对 tf.get_variable()的作用和 tf.Variable()的不同

tensorflow 中 name_scope和variable_scope的更多相关文章

  1. tensorflow 中 name_scope 及 variable_scope 的异同

    Let's begin by a short introduction to variable sharing. It is a mechanism in TensorFlow that allows ...

  2. tensorflow中使用tf.variable_scope和tf.get_variable的ValueError

    ValueError: Variable conv1/weights1 already exists, disallowed. Did you mean to set reuse=True in Va ...

  3. Tensorflow中的name_scope和variable_scope

    Tensorflow是一个编程模型,几乎成为了一种编程语言(里面有变量.有操作......). Tensorflow编程分为两个阶段:构图阶段+运行时. Tensorflow构图阶段其实就是在对图进行 ...

  4. TensorFlow学习笔记(1):variable与get_variable, name_scope()和variable_scope()

    Variable tensorflow中有两个关于variable的op,tf.Variable()与tf.get_variable()下面介绍这两个的区别 使用tf.Variable时,如果检测到命 ...

  5. [翻译] Tensorflow中name scope和variable scope的区别是什么

    翻译自:https://stackoverflow.com/questions/35919020/whats-the-difference-of-name-scope-and-a-variable-s ...

  6. TensorFlow中的变量命名以及命名空间.

    What: 在Tensorflow中, 为了区别不同的变量(例如TensorBoard显示中), 会需要命名空间对不同的变量进行命名. 其中常用的两个函数为: tf.variable_scope, t ...

  7. tensorflow中slim模块api介绍

    tensorflow中slim模块api介绍 翻译 2017年08月29日 20:13:35   http://blog.csdn.net/guvcolie/article/details/77686 ...

  8. name_scope与variable_scope 详解

    版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/lucky7213/article/deta ...

  9. 第二十二节,TensorFlow中的图片分类模型库slim的使用、数据集处理

    Google在TensorFlow1.0,之后推出了一个叫slim的库,TF-slim是TensorFlow的一个新的轻量级的高级API接口.这个模块是在16年新推出的,其主要目的是来做所谓的“代码瘦 ...

随机推荐

  1. P1596 【[USACO10OCT]湖计数Lake Counting】

    可爱的题面君~~ 个人感觉这题还是很简单的,就是一个完全不加工的找联通块个数 个人解题思路是先读入,然后循环一遍,遇到水就dfs,并把这个w所在的联通块“删除”,并在答案上加一 最后输出答案 具体注释 ...

  2. mysql——单表查询——其它整理示例01

    create database see; use database see; drop database sww; ========================================== ...

  3. 第十四周课程总结&&实验总结

    课程总结: 1.Java实现跨平台操作的工具:JDBC. 它的意思是java数据库连接,可以方便的实现多种关系型数据库的统一操作,它由一组用java语句编写的类和接口组成. 2.JDBC驱动分类: J ...

  4. 【Linux 网络编程】字节序和地址装换

    (3)字节序    <1>大端字节序        最高的有效位存储于最低内存地址处,最低有效位存储于最高内存地址处.    <2>小端字节序        最高的有效位存储于 ...

  5. sql server优化方向?

    系列转自KK:https://www.cnblogs.com/double-K/ Expert 诊断优化系列------------------你的CPU高么? Expert 诊断优化系列------ ...

  6. 小记---------spark组件与其他组件的比较 spark/mapreduce ;spark sql/hive ; spark streaming/storm

    Spark与Hadoop的对比   Scala是Spark的主要编程语言,但Spark还支持Java.Python.R作为编程语言 Hadoop的编程语言是Java    

  7. 360度3D 旋转插件

    Circlr插件是一款基于jQuery的可以对图片进行360度全方位旋转展示的插件.Circlr通过按一定角度规律拍摄的产品图片,制作出可以使用鼠标拖动.鼠标滚轮和移动触摸来进行图片逐帧旋转的效果.比 ...

  8. Linux普通用户无法使用sudo

    问题描述: jenkins执行发布脚本,因为使用的是jenkins用户,所以有些shell命令需要 sudo 来执行,导致报错. + sudo rm -rf /usr/share/nginx/html ...

  9. GitHub 上有哪些优秀的 Python 爬虫项目?

    目录 GitHub 上有哪些优秀的 Python 爬虫项目? 大型爬虫项目: 实用型爬虫项目: 其它有趣的Python爬虫小项目: GitHub 上有哪些优秀的 Python 爬虫项目? 大型爬虫项目 ...

  10. bootstrap modal 闪退的办法

     调用: