When using the TensorFlow Python API, I created a variable (without specifying its name
in the constructor), and its name
property had the value
The easiest way to get a variable by name is to search for it in the tf.global_variables() collection:
var_23 = [v for v in tf.global_variables() if v.name == "Variable_23:0"][0]
This works well for ad hoc reuse of existing variables. A more structured approach—for when you want to share variables between multiple parts of a model—is covered in the Sharing Variables tutorial.