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. python学习之内置函数(二)

    4.7.3 内置函数(2) int() str() bool() set() list():将一个可迭代对象转化为列表 tuple():将一个可迭代对象转换成元组 dic(): 通过相应的方式创建字典 ...

  2. HDU2196 Computer【换根dp】

    题目传送门 题意: 给定一个$N$个点的树,第$i$条边的长度是$A_i$,求每个点到其他所有点的最长距离.数据范围:$n ≤ 10000$,$A_i ≤ 10_9$ 分析 首先,从随便哪个节点($1 ...

  3. 使用UI Automation实现自动化测试--1-4

    Introduction UI Automation是Microsoft .NET 3.0框架下提供的一种用于自动化测试的技术,是在MSAA基础上建立的,MSAA就是Microsoft Active ...

  4. Oracle中的=:

    dept_code=:dCode =:在这里的意思是变量绑定

  5. linux查看cd/dvd驱动器的设备信息

    在linux下,如何来查看系统里的CD-ROM或者DVD驱动器的设备名呢? 你可以输入下面的命令来查看当前系统下的光盘驱动器信息: 1.使用dmesg命令来查看当前的硬件是否被linux内核正确的识别 ...

  6. (5.2)mysql高可用系列——测试环境部署

    关键词环境部署: ############## 测试环境机器架构 #########[1]策划[1.1]linux服务器A组 8台 192.168.1.200~192.168.1.207,主机名db, ...

  7. Python基础数据类型str字符串

    3.3字符串str ' ' 0 切片选取 [x:y] 左闭右开区间 [x:y:z] 选取x到y之间 每隔z选取一次(选取x,x+z,....) z为正 索引位置:x在y的左边 z为负 索引位置:x在y ...

  8. Longest Subsequence CodeForces - 632D (lcm)

    大意: 给定序列$a$, 求选出最长的一个子序列, 使得lcm不超过m. 刚开始想复杂了, 想着枚举gcd然后背包, 这样复杂度就是$O(\sum\limits_{i=1}^m \frac{m\sig ...

  9. RabbitMQ入门教程(九):首部交换机Headers

    原文:RabbitMQ入门教程(九):首部交换机Headers 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog ...

  10. CF528E Triangles 3000

    cf luogu 既然要求三角形面积,不如考虑三角形的面积公式.因为是三条直线,所以可以考虑利用三个交点来算面积,如果这个三角形按照逆时针方向有\(ABC\)三点,那么他的面积为\(\frac{\ve ...