The difference and connection of variable naming

1、tf.variable(<variable_name>)与tf.get_variable(<variable_name>):

When the former creates a variable, it will automatically deal with the same variable when it encounters it. The way to deal with it is to rename it, like 1-1, 1-1-1. When the latter creates a variable, it actually acquires the variable. When the variable exists, it is directly acquired, and when the variable does not exist, it is created.

2、tf.name_scope(<scope_name>)与tf.variable_scope(<scope_name>):

tf.name_scope(<scope_name>) returns a context manager named scope_name, which is mostly used for graph management. When creating a variable with the same name, an error will be reported.

tf.variable_scope(<scope_name>) A variable that can be shared. If there is a duplicate name, no error will be reported, and it is regarded as a shared variable.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325347114&siteId=291194637