r""" Compute the layer output on a single minibatch. Parameters ---------- X : list of length `n_inputs` A list of tensors, all of the same shape. retain_derived : bool Whether to retain the variables calculated during the forward pass
(self, X, retain_derived=True)
| 684 | } |
| 685 | |
| 686 | def forward(self, X, retain_derived=True): |
| 687 | r""" |
| 688 | Compute the layer output on a single minibatch. |
| 689 | |
| 690 | Parameters |
| 691 | ---------- |
| 692 | X : list of length `n_inputs` |
| 693 | A list of tensors, all of the same shape. |
| 694 | retain_derived : bool |
| 695 | Whether to retain the variables calculated during the forward pass |
| 696 | for use later during backprop. If False, this suggests the layer |
| 697 | will not be expected to backprop through wrt. this input. Default |
| 698 | is True. |
| 699 | |
| 700 | Returns |
| 701 | ------- |
| 702 | Y : :py:class:`ndarray <numpy.ndarray>` of shape `(n_ex, *)` |
| 703 | The sum over the `n_ex` examples. |
| 704 | """ |
| 705 | out = X[0].copy() |
| 706 | for i in range(1, len(X)): |
| 707 | out += X[i] |
| 708 | if retain_derived: |
| 709 | self.X.append(X) |
| 710 | self.derived_variables["sum"].append(out) |
| 711 | return self.act_fn(out) |
| 712 | |
| 713 | def backward(self, dLdY, retain_grads=True): |
| 714 | r""" |