tensorflow: name_scope 和 variable_scope的差别
来源:互联网 发布:python rsa 加密 编辑:程序博客网 时间:2024/06/05 09:45
Variable sharing 简介
因为我目前对variable_scope 的理解,这个功能主要是是针对Variable sharing 来做的,所以先介绍一下variable sharing:
主要有两种方法实现
* 直接在各个ops,function之间传递variable reference.
* 把variable 封装在variable_scope/name_scope 中
variable_scop/name_scope简介
这两种scope最直接的影响是: 所有在scope下面创建的variable都会把这个scope的名字作为前缀。比如如下代码
with tf.name_scope("my_scope"): v1 = tf.get_variable("var1", [1], dtype=tf.float32) v2 = tf.Variable(1, name="var2", dtype=tf.float32)with tf.variable_scope("my_scope"): v3 = tf.get_variable("var1", [1], dtype=tf.float32) v4 = tf.Variable(1, name="var2", dtype=tf.float32)print("v1:",v1)print("v2:",v2)print("v3:",v3)print("v4:",v4)
输出结果如下
v1: <tf.Variable 'var1:0' shape=(1,) dtype=float32_ref>v2: <tf.Variable 'my_scope/var2:0' shape=() dtype=float32_ref>v3: <tf.Variable 'my_scope/var1:0' shape=(1,) dtype=float32_ref>v4: <tf.Variable 'my_scope_1/var2:0' shape=() dtype=float32_ref>
name_scope 与 variable_scope的差别
细心的同学可能已经主要到了,在上面的输出中,v1 没有my_scope的前缀。这个就是name_scope 和variable_scope的差别:
tf.get_variable 会忽略 name_scope
这个功能允许我们在不同的name_scope里面也能共享variable
阅读全文
1 0
- tensorflow: name_scope 和 variable_scope的差别
- Tensorflow name_scope和variable_scope的区别
- TensorFlow中,variable_scope和name_scope的不同之处
- tensorflow 中 name_scope和variable_scope
- TensorFlow:作用域name_scope和variable_scope
- tensorflow 中 name_scope 及 variable_scope 的异同
- Tensorflow-variable_scope,name_scope
- tensorflow name_scope variable_scope
- tensorflow variable_scope\name_scope
- tensorflow name_scope && variable_scope
- tf.variable_scope和tf.name_scope的用法
- tensorflow 中的 name_scope 与 variable_scope
- TensorFlow基础name_scope与variable_scope
- tensorflow:上下文管理器 与 name_scope, variable_scope
- tensorflow 中 variable_scope 与name_scope函数解析
- tensorflow的共享变量,tf.Variable(),tf.get_variable(),tf.Variable_scope(),tf.name_scope()联系与区别:
- tensorflow学习之路(2-1):tf.variable_scope(), tf.name_scope(), tf.get_variable()的认识
- tensorflow学习之路(2-2):tf.variable_scope(),tf.name_scope(),tf.get_variable()的认识(补充)
- JavaScript实现"继承"
- hmail汉化步骤详解
- VS + QT +FFTW
- Android开发 之 WebView的版本变化
- 每天一个linux命令(43):killall命令
- tensorflow: name_scope 和 variable_scope的差别
- 虚函数和纯虚函数的区别
- Ros学习笔记(十):理解 launch文件
- poj 3070 Fibonacci
- 判断String是否为数值,包括小数和负数
- RTP 打包H.264
- ubuntu桌面程序启动器
- android studio 常用快捷键集锦
- git clone ssh地址时一直提示Permission denied, please try again