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. Opencv中copyTo()函数的使用方法

    在Mat矩阵类的成员函数中copyTo(roi , mask)函数是非常有用的一个函数,尤其是后面的mask可以实现蒙版的功能,我们用几个实例来说明它的作用.我们要注意mask的数据类型,必须是CV_ ...

  2. Day02:变量 / JAVA基本类型

    变量 什么是变量? 变化数值的载体 变量声明.初始化.使用 声明变量  类型 大小(占用空间) int x; 初始化变量 (赋值) 给予占用空间 int x=35; 使用变量 直接使用变量名 注意: ...

  3. cocos2dx[3.2](2) 3.x巨变

    [v3.0 亮点]     > 使用 C++(C++11) 的特性取代了 Objective-C 的特性     > 优化了 Labels     > 优化了渲染器(比 v2.2 更 ...

  4. PHP操作redis部分命令

    //连接本地的 Redis 服务 $redis = new Redis(); $redis->connect('127.0.0.1', 6379); $redis->auth('12345 ...

  5. #Java学习之路——基础阶段二(第十三篇)

    我的学习阶段是跟着CZBK黑马的双源课程,学习目标以及博客是为了审查自己的学习情况,毕竟看一遍,敲一遍,和自己归纳总结一遍有着很大的区别,在此期间我会参杂Java疯狂讲义(第四版)里面的内容. 前言: ...

  6. POJ3585 Accumulation Degree【换根dp】

    题目传送门 题意 给出一棵树,树上的边都有容量,在树上任意选一个点作为根,使得往外流(到叶节点,叶节点可以接受无限多的流量)的流量最大. 分析 首先,还是从1号点工具人开始$dfs$,可以求出$dp[ ...

  7. webdriver中判断元素是否存在的方法

    selenium.webdriver中没有内置的判断元素是否存在的方法,所以定义一个方法,如果找到该元素则返回True,否则返回False: from selenium import webdrive ...

  8. 反复横跳的瞄准线!从向量计算说起!基于射线检测的实现!Cocos Creator!

    最近有小伙伴问我瞄准线遇到各种形状该怎么处理?如何实现反复横跳的瞄准线?最近刚好在<Cocos Creator游戏开发实战>中看到物理系统有一个射线检测,于是,基于这个射线检测,写了一个反 ...

  9. HDU 2809 God of War (状压DP)

    God of War Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  10. poj2352(树状数组)

    题目链接:https://vjudge.net/problem/POJ-2352 题意:在直角坐标系中给出n个点的 (x,y),(0<=x,y<=32000),定义每个点的level为(x ...