Tensorflow name_scope和variable_scope的区别
来源:互联网 发布:淘宝怎么搜潮流的衣服 编辑:程序博客网 时间:2024/06/07 03:30
为了研究一下tensorflow的name_scope
和variable_scope
到底有啥区别,我对Variable和Summary对象分别试验了这两种scope。直接上代码:
1.对Variable先加name_scope
,再加variable_scope
import tensorflow as tfwith tf.name_scope('ns1'): #name_scope v1 = tf.get_variable('v1', shape=(1,)) with tf.variable_scope('vs1'): #variable_scope v2 = tf.get_variable('v2', shape=(1,))v1v2_coll = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES,scope='ns1') #[]v2_coll = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES,scope='vs1') #'vs1/v2:0'#name_scope对变量无效, 'vs1/v2:0'的prefix里没有'ns1/'
2.对Variable先加variable_scope
,再加name_scope
with tf.variable_scope('vs2'): #variable_scope v1 = tf.get_variable('v1', shape=(1,)) with tf.name_scope('ns2'): #name_scope v2 = tf.get_variable('v2', shape=(1,))v1v2_coll = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES,scope='vs2') #'vs2/v1:0'v2_coll = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES,scope='ns2') #[]#name_scope对变量无效, 'vs2/v1:0'的prefix里没有'ns2/'
3.对Summary先加name_scope
,再加variable_scope
with tf.name_scope('ns3'): #name_scope tf.summary.histogram('sum_ns', tf.convert_to_tensor([1])) with tf.variable_scope('vs3'): #variable_scope tf.summary.histogram('sum_nsvs', tf.convert_to_tensor([1]))sum_ns_coll = tf.get_collection(tf.GraphKeys.SUMMARIES,scope='ns3')#'ns3/sum_ns:0', 'ns3/vs3/sum_vs:0'sum_nsvs_coll = tf.get_collection(tf.GraphKeys.SUMMARIES,scope='ns3/vs3')#'ns3/vs3/sum_nsvs:0'
4.对Summary先加variable_scope
,再加name_scope
with tf.variable_scope('vs4'): #variable_scope tf.summary.histogram('sum_vs', tf.convert_to_tensor([1])) with tf.name_scope('ns4'): #name_scope tf.summary.histogram('sum_ns', tf.convert_to_tensor([1]))sum_vs_coll = tf.get_collection(tf.GraphKeys.SUMMARIES,scope='vs4')#'vs4/sum_vs:0', 'vs4/ns4/sum_ns:0'sum_vsns_coll = tf.get_collection(tf.GraphKeys.SUMMARIES,scope='vs4/ns4')#'vs4/ns4/sum_ns:0'
0 1
- 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 中 name_scope 及 variable_scope 的异同
- Tensorflow-variable_scope,name_scope
- tensorflow name_scope variable_scope
- tensorflow variable_scope\name_scope
- tensorflow name_scope && variable_scope
- tensorflow的共享变量,tf.Variable(),tf.get_variable(),tf.Variable_scope(),tf.name_scope()联系与区别:
- tensorflow的共享变量,tf.Variable(),tf.get_variable(),tf.Variable_scope(),tf.name_scope()联系与区别
- tensorflow的共享变量,tf.Variable(),tf.get_variable(),tf.Variable_scope(),tf.name_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函数解析
- java存储时间date到mysql的datetime格式的方法
- 关于servlet的request对象
- FileWriter和BufferedWriter区别和用法(附加java书上7.4的题目!!)
- 51nod 1284【容斥】
- hadoop平台使用python编写mapreduce排序小程序
- Tensorflow name_scope和variable_scope的区别
- Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found解决办法
- Tensorflow 共享变量
- HDU 1232 畅通工程
- C的|、||、&、&&、异或^、~、!运算符
- DT科技评论第35期:可以解锁任何手机的万能指纹
- Hexo+GitHub搭建个人站点(新!)
- 比特币的小额支付通道
- Ubuntu16.04 中 phpmyadmin安装 mysql卸载 mysql外部访问