def is_same_graph_with_merge(var1, var2, givens=None):
 if (givens is None):
  givens = {}
 copied = copy.deepcopy([var1, var2, givens])
 vars = copied[0:2]
 givens = copied[2]
 inputs = theano.gof.graph.inputs(vars)
 fgraph = theano.gof.fg.FunctionGraph(inputs, vars, clone=False)
 for (to_replace, replace_by) in iteritems(givens):
  fgraph.replace(to_replace, replace_by)
 MergeOptimizer().optimize(fgraph)
 vars_replaced = [givens.get(v, v) for v in vars]
 (o1, o2) = [v.owner for v in vars_replaced]
 if ((o1 is None) and (o2 is None)):
  return (vars_replaced[0] == vars_replaced[1])
 else:
  return (o1 is o2)

def is_same_graph_with_merge ( var1 , var2 , givens = None ) : if ( givens is None ) : givens = { } copied = copy . deepcopy ( [ var1 , var2 , givens ] ) vars = copied [ 0 : 2 ] givens = copied [ 2 ] inputs = theano . gof . graph . inputs ( vars ) fgraph = theano . gof . fg . FunctionGraph ( inputs , vars , clone = False ) for ( to_replace , replace_by ) in iteritems ( givens ) : fgraph . replace ( to_replace , replace_by ) MergeOptimizer ( ) . optimize ( fgraph ) vars_replaced = [ givens . get ( v , v ) for v in vars ] ( o1 , o2 ) = [ v . owner for v in vars_replaced ] if ( ( o1 is None ) and ( o2 is None ) ) : return ( vars_replaced [ 0 ] == vars_replaced [ 1 ] ) else : return ( o1 is o2 )
merge-based implementation of theano .