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. java:maven(maven-ssm(聚合,分包开发))

    1.maven-ssm: maven-ssm_diy: pom.xml: <?xml version="1.0" encoding="UTF-8"?> ...

  2. WebLogic下Argument(s) "type" can't be null.

    启动项目出现Argument(s) "type" can't be null.异常.异常如下: java.lang.IllegalArgumentException: Argume ...

  3. 【HANA系列】SAP HANA SQL/MDX及TCP/IP端口介绍

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[HANA系列]SAP HANA SQL/MDX ...

  4. 利用python求非线性方程

    最近在做的东西中有一件任务,相当于一个函数已知y来求x,网上找了各种办法最终得以实现.在此说明方法,并记录一些坑. 要求的函数比如:log(x) - log(1-x) + 2.2 * (1 -2x) ...

  5. Java 并发编程:核心理论(一)

    前言......... 并发编程是Java程序员最重要的技能之一,也是最难掌握的一种技能.它要求编程者对计算机最底层的运作原理有深刻的理解,同时要求编程者逻辑清晰.思维缜密,这样才能写出高效.安全.可 ...

  6. HDU 1171 Big Event in HDU (动态规划、01背包)

    Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  7. nodejs以对象做对象的key导致value一直被覆盖

      问题描述 在开发中,实现技能状态的事件监听功能时,将状态对象作为key,存入事件管理器的监听列表,如下图: 实现后,运行程序,并没有报错,但是当某个事件发生时,只有一个状态被触发监听,而大多数状态 ...

  8. [转帖]Linux修改时区

    公司一台国产服务器的时间总是错的 我用 date -R 出来的结果 是 +7.0 修改办法就是 这个文档来里面的 https://www.cnblogs.com/royfans/p/8056270.h ...

  9. Java 将Maven项目打成可执行jar包

    一.用maven-shade-plugin打包 在pom.xml文件中加入如下信息,利用Maven的maven-shade-plugin插件进行打包. <build> <plugin ...

  10. Appium+Python之获取toast

    思考:手机APP上的必填或错误文本提示一般1-2s就会消失,比较难定位,所以一般的固定元素定位方式是不可用的,那我们如何定位toast呢? 前提:1.Appium1.6.3以上(包括1.6.3) 2. ...