Specifies a three-dimensional local connection between one or two population of neurons supporting multi-channel inputs with shape (C, H, W, D); The logic is different from the original LocalConnection implementation (where masks were used with normal dense connections)
| 1768 | |
| 1769 | |
| 1770 | class LocalConnection3D(AbstractConnection): |
| 1771 | """ |
| 1772 | Specifies a three-dimensional local connection between one or two population of neurons supporting multi-channel inputs with shape (C, H, W, D); |
| 1773 | The logic is different from the original LocalConnection implementation (where masks were used with normal dense connections) |
| 1774 | """ |
| 1775 | |
| 1776 | def __init__( |
| 1777 | self, |
| 1778 | source: Nodes, |
| 1779 | target: Nodes, |
| 1780 | kernel_size: Union[int, Tuple[int, int, int]], |
| 1781 | stride: Union[int, Tuple[int, int, int]], |
| 1782 | n_filters: int, |
| 1783 | nu: Optional[Union[float, Sequence[float], Sequence[torch.Tensor]]] = None, |
| 1784 | reduction: Optional[callable] = None, |
| 1785 | weight_decay: float = 0.0, |
| 1786 | w_dtype: torch.dtype = torch.float32, |
| 1787 | **kwargs, |
| 1788 | ) -> None: |
| 1789 | """ |
| 1790 | Instantiates a 'LocalConnection3D` object. Source population can be multi-channel. |
| 1791 | Neurons in the post-synaptic population are ordered by receptive field, i.e., |
| 1792 | if there are `n_conv` neurons in each post-synaptic patch, then the first |
| 1793 | `n_conv` neurons in the post-synaptic population correspond to the first |
| 1794 | receptive field, the second ``n_conv`` to the second receptive field, and so on. |
| 1795 | :param source: A layer of nodes from which the connection originates. |
| 1796 | :param target: A layer of nodes to which the connection connects. |
| 1797 | :param kernel_size: Horizontal, vertical, and depth-wise size of convolutional kernels. |
| 1798 | :param stride: Horizontal, vertical, and depth-wise stride for convolution. |
| 1799 | :param n_filters: Number of locally connected filters per pre-synaptic region. |
| 1800 | :param nu: Learning rate for both pre- and post-synaptic events. It also |
| 1801 | accepts a pair of tensors to individualize learning rates of each neuron. |
| 1802 | In this case, their shape should be the same size as the connection weights. |
| 1803 | :param reduction: Method for reducing parameter updates along the minibatch dimension. |
| 1804 | :param weight_decay: Constant multiple to decay weights by on each iteration. |
| 1805 | :param w_dtype: Data type for :code:`w` tensor |
| 1806 | Keyword arguments: |
| 1807 | :param LearningRule update_rule: Modifies connection parameters according to some rule. |
| 1808 | :param torch.Tensor w: Strengths of synapses. |
| 1809 | :param torch.Tensor b: Target population bias. |
| 1810 | :param float wmin: Minimum allowed value on the connection weights. |
| 1811 | :param float wmax: Maximum allowed value on the connection weights. |
| 1812 | :param float norm: Total weight per target neuron normalization constant. |
| 1813 | """ |
| 1814 | |
| 1815 | super().__init__(source, target, nu, reduction, weight_decay, **kwargs) |
| 1816 | |
| 1817 | kernel_size = _triple(kernel_size) |
| 1818 | stride = _triple(stride) |
| 1819 | |
| 1820 | self.kernel_size = kernel_size |
| 1821 | self.stride = stride |
| 1822 | self.n_filters = n_filters |
| 1823 | |
| 1824 | self.in_channels, input_height, input_width, input_depth = ( |
| 1825 | source.shape[0], |
| 1826 | source.shape[1], |
| 1827 | source.shape[2], |