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)
| 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""" |