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

Method forward

numpy_ml/neural_nets/layers/layers.py:2090–2120  ·  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

2088 }
2089
2090 def forward(self, X, retain_derived=True):
2091 """
2092 Compute the layer output on a single minibatch.
2093
2094 Parameters
2095 ----------
2096 X : :py:class:`ndarray <numpy.ndarray>` of shape `(n_ex, n_in)`
2097 Layer input, representing the `n_in`-dimensional features for a
2098 minibatch of `n_ex` examples.
2099 retain_derived : bool
2100 Whether to retain the variables calculated during the forward pass
2101 for use later during backprop. If False, this suggests the layer
2102 will not be expected to backprop through wrt. this input. Default
2103 is True.
2104
2105 Returns
2106 -------
2107 Y : :py:class:`ndarray <numpy.ndarray>` of shape `(n_ex, n_out)`
2108 Layer output for each of the `n_ex` examples.
2109 """
2110 if not self.is_initialized:
2111 self.n_in = X.shape[1]
2112 self._init_params()
2113
2114 Y, Z = self._fwd(X)
2115
2116 if retain_derived:
2117 self.X.append(X)
2118 self.derived_variables["Z"].append(Z)
2119
2120 return Y
2121
2122 def _fwd(self, X):
2123 """Actual computation of forward pass"""

Callers 1

test_FullyConnectedFunction · 0.95

Calls 2

_init_paramsMethod · 0.95
_fwdMethod · 0.95

Tested by 1

test_FullyConnectedFunction · 0.76