MCPcopy Create free account
hub / github.com/rushter/MLAlgorithms / Dropout

Class Dropout

mla/neuralnet/layers/basic.py:110–131  ·  view source on GitHub ↗

Randomly set a fraction of `p` inputs to 0 at each training update.

Source from the content-addressed store, hash-verified

108
109
110class Dropout(Layer, PhaseMixin):
111 """Randomly set a fraction of `p` inputs to 0 at each training update."""
112
113 def __init__(self, p=0.1):
114 self.p = p
115 self._mask = None
116
117 def forward_pass(self, X):
118 assert self.p > 0
119 if self.is_training:
120 self._mask = np.random.uniform(size=X.shape) > self.p
121 y = X * self._mask
122 else:
123 y = X * (1.0 - self.p)
124
125 return y
126
127 def backward_pass(self, delta):
128 return delta * self._mask
129
130 def shape(self, x_shape):
131 return x_shape
132
133
134class TimeStepSlicer(Layer):

Callers 4

clasifierFunction · 0.90
test_mlpFunction · 0.90
classificationFunction · 0.90

Calls

no outgoing calls

Tested by 2

clasifierFunction · 0.72
test_mlpFunction · 0.72