MCPcopy
hub / github.com/ddbourgin/numpy-ml / forward

Method forward

numpy_ml/neural_nets/layers/layers.py:2263–2292  ·  view source on GitHub ↗

Compute the layer output on a single minibatch. Parameters ---------- X : :py:class:`ndarray ` of shape `(n_ex, n_in)` Layer input, representing the `n_in`-dimensional features for a minibatch of `n_ex` examples. retain

(self, X, retain_derived=True)

Source from the content-addressed store, hash-verified

2261 }
2262
2263 def forward(self, X, retain_derived=True):
2264 """
2265 Compute the layer output on a single minibatch.
2266
2267 Parameters
2268 ----------
2269 X : :py:class:`ndarray <numpy.ndarray>` of shape `(n_ex, n_in)`
2270 Layer input, representing the `n_in`-dimensional features for a
2271 minibatch of `n_ex` examples.
2272 retain_derived : bool
2273 Whether to retain the variables calculated during the forward pass
2274 for use later during backprop. If False, this suggests the layer
2275 will not be expected to backprop through wrt. this input. Default
2276 is True.
2277
2278 Returns
2279 -------
2280 Y : :py:class:`ndarray <numpy.ndarray>` of shape `(n_ex, n_out)`
2281 Layer output for each of the `n_ex` examples.
2282 """
2283 if not self.is_initialized:
2284 self.n_in = X.shape[1]
2285 self._init_params()
2286
2287 Y = self._fwd(X)
2288
2289 if retain_derived:
2290 self.X.append(X)
2291
2292 return Y
2293
2294 def _fwd(self, X):
2295 """Actual computation of softmax forward pass"""

Callers 3

test_cross_entropy_gradFunction · 0.95
test_softmax_activationFunction · 0.95
test_softmax_gradFunction · 0.95

Calls 2

_init_paramsMethod · 0.95
_fwdMethod · 0.95

Tested by 3

test_cross_entropy_gradFunction · 0.76
test_softmax_activationFunction · 0.76
test_softmax_gradFunction · 0.76