zoukankan      html  css  js  c++  java
  • tensorflow--variable_scope

    1.with tf.variable_scope(name , reuse = reuse)

    (1)创建variable scope

    with tf.variable_scope("foo"):
        with tf.variable_scope("bar"):
            v = tf.get_variable("v", [1])
            assert v.name == "foo/bar/v:0"

    (2)共享变量

    with tf.variable_scope("foo"):
        v = tf.get_variable("v", [1])
    with tf.variable_scope("foo", reuse=True):
        v1 = tf.get_variable("v", [1])
    assert v1 == v
    

    (3)在一个变量域中,不允许重用变量

    with tf.variable_scope("foo"):
        v = tf.get_variable("v", [1])
        v1 = tf.get_variable("v", [1])
        #  Raises ValueError("... v already exists ...").
    

    (4)当试图获取在重用模式中不存在的变量时,我们会引发异常

    with tf.variable_scope("foo", reuse=True):
        v = tf.get_variable("v", [1])
        #  Raises ValueError("... v does not exists ...").
  • 相关阅读:
    Linux文件及目录查找
    英语单词independent
    英语单词omitting
    英语单词deploy
    英语单词debug
    线程
    进程
    操作系统历史
    分布式爬虫
    爬虫基础
  • 原文地址:https://www.cnblogs.com/ChenKe-cheng/p/9968207.html
Copyright © 2011-2022 走看看