tf.name_scope 對(duì) tf.get_variable 與 tf.Variable 的影響
-
tf.Variable 會(huì)加上 name_scope 的名字前綴, tf.get_variable 不會(huì)(同時(shí)以為 tf.get_variable 沒(méi)有加 name_scope 的前綴,所以是全局變量,不在 name_scope 中,也無(wú)法 get_variable 創(chuàng)建同樣的 name 的變量)
image.png
tf.variable_scope 對(duì) tf.get_variable 與 tf.Variable 的影響
-
tf.Variable 會(huì)加上 variable_scope 的名字前綴,tf.Variable碰到相同的變量會(huì)自動(dòng)加名字, tf.get_variable 也會(huì)(同時(shí)以為 tf.get_variable 加 variable_scope 的前綴,同一個(gè)variable_scope中,只可以創(chuàng)作一個(gè) name 的 get_variable, 如果需要variable_scope中共享同一個(gè) name 的get_variable,需要設(shè)置參數(shù) reuse=True)
image.png
image.png
image.png
image.png