python - What is the 'name' field used for in the definition of a theano shared variable? -


i notice can define theano shared variable by:

theano.shared(value, name=none, strict=false, allow_downcast=none, **kwargs) 

in theano doc here, says name field "the name variable". see in cases people pass same string name field shared variable's name in python. example:

a = theano.shared(1, "a")  

what rule of thumb define name field? name field used for?

assigning names theano objects helps during debugging. example, theano.printing.debugprint include name, if present, in output; can make understanding complex computation graph easier.

you can give names input variables (e.g. x=theano.tensor.scalar('x')) , functions (e.g. f=theano.function(inputs, outputs, name='f').

the output of theano.printing.debugprint can limited naming nodes content don't need see , using stop_on_name parameter.

keep python names , theano names in sync can tedious , error prone. in circumstances might use functions such as:

def name_node(variable, variable_names):     name, query_variable in variable_names.iteritems():         if query_variable variable:             variable.name = name      return variable   def name_nodes(variables, variable_names):     if not isinstance(variables, (tuple, list)):         return name_node(variables, variable_names)      variable in variables:         name, query_variable in variable_names.iteritems():             if query_variable variable:                 variable.name = name      return variables 

in symbolic function can use these this:

def create_graph(w_filename):     x = t.scalar()     w = theano.shared(numpy.load(w_filename))     y = t.tanh(theano.dot(x, w))     return name_nodes([x, w, y], locals()) 

this bit of python hack , won't suitable in circumstances.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -