mardi 14 juin 2016

Get all tf.Variables related to a specific tensor in TensorFlow


I want to create a utility function where I give it a tensor t and a variable name n, and the function returns (it it exists) the variable whos name contains n and is part of the graph of t.

def get_variable(t, n):
   #code
   return variable

The reason I want to do this is that using Jupyter I often create a graph multiple times while deciding the best structure, but the tensor names keep changing to something like: {name}_{repetition}:0, so finding them through tf.all_variables() becomes increasingly harder.

It would be easier if I could limit the search to the variables related to a specific tensor because its identifier is of the latest repetition.


Aucun commentaire:

Enregistrer un commentaire