Wrappers¶
WrapperBase¶
-
class
numpy_ml.neural_nets.wrappers.wrappers.WrapperBase(wrapped_layer)[source]¶ An abstract base class for all Wrapper instances
-
freeze()[source]¶ Freeze the base layer’s parameters at their current values so they can no longer be updated.
-
update(lr)[source]¶ Update the base layer’s parameters using the accrued gradients and layer optimizer. Flush all gradients once the update is complete.
-
set_params(summary_dict)[source]¶ Set the base layer parameters from a dictionary of values.
Parameters: summary_dict (dict) – A dictionary of layer parameters and hyperparameters. If a required parameter or hyperparameter is not included within summary_dict, this method will use the value in the current layer’s summary()method.Returns: layer (Layer object) – The newly-initialized layer.
-
Dropout¶
-
class
numpy_ml.neural_nets.wrappers.Dropout(wrapped_layer, p)[source]¶ Bases:
numpy_ml.neural_nets.wrappers.wrappers.WrapperBaseA dropout regularization wrapper.
Notes
During training, a dropout layer zeroes each element of the layer input with probability p and scales the activation by 1 / (1 - p) (to reflect the fact that on average only (1 - p) * N units are active on any training pass). At test time, does not adjust elements of the input at all (ie., simply computes the identity function).
Parameters: - wrapped_layer (Layer instance) – The layer to apply dropout to.
- p (float in [0, 1)) – The dropout propbability during training
-
forward(X, retain_derived=True)[source]¶ Compute the layer output with dropout for a single minibatch.
Parameters: - X (
ndarrayof shape (n_ex, n_in)) – Layer input, representing the n_in-dimensional features for a minibatch of n_ex examples. - retain_derived (bool) – Whether to retain the variables calculated during the forward pass for use later during backprop. If False, this suggests the layer will not be expected to backprop through wrt. this input. Default is True.
Returns: Y (
ndarrayof shape (n_ex, n_out)) – Layer output for each of the n_ex examples.- X (