def apply_dropout(computation_graph, variables, drop_prob, rng=None, seed=None, custom_divisor=None):
 if ((not rng) and (not seed)):
  seed = config.default_seed
 if (not rng):
  rng = MRG_RandomStreams(seed)
 if (custom_divisor is None):
  divisor = (1 - drop_prob)
 else:
  divisor = custom_divisor
 replacements = [(var, ((var * rng.binomial(var.shape, p=(1 - drop_prob), dtype=theano.config.floatX)) / divisor)) for var in variables]
 for (variable, replacement) in replacements:
  add_role(replacement, DROPOUT)
  replacement.tag.replacement_of = variable
 return computation_graph.replace(replacements)

def apply_dropout ( computation_graph , variables , drop_prob , rng = None , seed = None , custom_divisor = None ) : if ( ( not rng ) and ( not seed ) ) : seed = config . default_seed if ( not rng ) : rng = MRG_RandomStreams ( seed ) if ( custom_divisor is None ) : divisor = ( 1 - drop_prob ) else : divisor = custom_divisor replacements = [ ( var , ( ( var * rng . binomial ( var . shape , p = ( 1 - drop_prob ) , dtype = theano . config . floatX ) ) / divisor ) ) for var in variables ] for ( variable , replacement ) in replacements : add_role ( replacement , DROPOUT ) replacement . tag . replacement_of = variable return computation_graph . replace ( replacements )
apply dropout to specified variables in a graph .