def sampled_dropout_average(mlp, inputs, num_masks, default_input_include_prob=0.5, input_include_probs=None, default_input_scale=2.0, input_scales=None, rng=(2013, 5, 17), per_example=False):
 if (input_include_probs is None):
  input_include_probs = {}
 if (input_scales is None):
  input_scales = {}
 if (not hasattr(rng, 'uniform')):
  rng = np.random.RandomState(rng)
 mlp._validate_layer_names(list(input_include_probs.keys()))
 mlp._validate_layer_names(list(input_scales.keys()))
 if per_example:
  outputs = [mlp.dropout_fprop(inputs, default_input_include_prob, input_include_probs, default_input_scale, input_scales) for _ in xrange(num_masks)]
 else:
  masks = [generate_dropout_mask(mlp, default_input_include_prob, input_include_probs, rng) for _ in xrange(num_masks)]
  outputs = [mlp.masked_fprop(inputs, mask, None, default_input_scale, input_scales) for mask in masks]
 return geometric_mean_prediction(outputs)

def sampled_dropout_average ( mlp , inputs , num_masks , default_input_include_prob = 0.5 , input_include_probs = None , default_input_scale = 2.0 , input_scales = None , rng = ( 2013 , 5 , 17 ) , per_example = False ) : if ( input_include_probs is None ) : input_include_probs = { } if ( input_scales is None ) : input_scales = { } if ( not hasattr ( rng , 'uniform' ) ) : rng = np . random . RandomState ( rng ) mlp . _validate_layer_names ( list ( input_include_probs . keys ( ) ) ) mlp . _validate_layer_names ( list ( input_scales . keys ( ) ) ) if per_example : outputs = [ mlp . dropout_fprop ( inputs , default_input_include_prob , input_include_probs , default_input_scale , input_scales ) for _ in xrange ( num_masks ) ] else : masks = [ generate_dropout_mask ( mlp , default_input_include_prob , input_include_probs , rng ) for _ in xrange ( num_masks ) ] outputs = [ mlp . masked_fprop ( inputs , mask , None , default_input_scale , input_scales ) for mask in masks ] return geometric_mean_prediction ( outputs )
take the geometric mean over a number of randomly sampled dropout masks for an mlp with softmax outputs .