def generate_dropout_mask(mlp, default_include_prob=0.5, input_include_probs=None, rng=(2013, 5, 17)):
 if (input_include_probs is None):
  input_include_probs = {}
 if (not hasattr(rng, 'uniform')):
  rng = np.random.RandomState(rng)
 total_units = 0
 mask = 0
 for layer in mlp.layers:
  if (layer.layer_name in input_include_probs):
   p = input_include_probs[layer.layer_name]
  else:
   p = default_include_prob
  for _ in xrange(layer.get_input_space().get_total_dimension()):
   mask |= (int((rng.uniform() < p)) << total_units)
   total_units += 1
 return mask

def generate_dropout_mask ( mlp , default_include_prob = 0.5 , input_include_probs = None , rng = ( 2013 , 5 , 17 ) ) : if ( input_include_probs is None ) : input_include_probs = { } if ( not hasattr ( rng , 'uniform' ) ) : rng = np . random . RandomState ( rng ) total_units = 0 mask = 0 for layer in mlp . layers : if ( layer . layer_name in input_include_probs ) : p = input_include_probs [ layer . layer_name ] else : p = default_include_prob for _ in xrange ( layer . get_input_space ( ) . get_total_dimension ( ) ) : mask |= ( int ( ( rng . uniform ( ) < p ) ) << total_units ) total_units += 1 return mask
generate a dropout mask given inclusion probabilities .