MCPcopy Create free account
hub / github.com/BindsNET/bindsnet / LocalConnection2D

Class LocalConnection2D

bindsnet/network/topology.py:1623–1767  ·  view source on GitHub ↗

Specifies a two-dimensional local connection between one or two population of neurons supporting multi-channel inputs with shape (C, H, W); The logic is different from the original LocalConnection implementation (where masks were used with normal dense connections)

Source from the content-addressed store, hash-verified

1621
1622
1623class LocalConnection2D(AbstractConnection):
1624 """
1625 Specifies a two-dimensional local connection between one or two population of neurons supporting multi-channel inputs with shape (C, H, W);
1626 The logic is different from the original LocalConnection implementation (where masks were used with normal dense connections)
1627 """
1628
1629 def __init__(
1630 self,
1631 source: Nodes,
1632 target: Nodes,
1633 kernel_size: Union[int, Tuple[int, int]],
1634 stride: Union[int, Tuple[int, int]],
1635 n_filters: int,
1636 nu: Optional[Union[float, Sequence[float], Sequence[torch.Tensor]]] = None,
1637 reduction: Optional[callable] = None,
1638 weight_decay: float = 0.0,
1639 w_dtype: torch.dtype = torch.float32,
1640 **kwargs,
1641 ) -> None:
1642 """
1643 Instantiates a 'LocalConnection2D` object. Source population can be multi-channel.
1644 Neurons in the post-synaptic population are ordered by receptive field, i.e.,
1645 if there are `n_conv` neurons in each post-synaptic patch, then the first
1646 `n_conv` neurons in the post-synaptic population correspond to the first
1647 receptive field, the second ``n_conv`` to the second receptive field, and so on.
1648 :param source: A layer of nodes from which the connection originates.
1649 :param target: A layer of nodes to which the connection connects.
1650 :param kernel_size: Horizontal and vertical size of convolutional kernels.
1651 :param stride: Horizontal and vertical stride for convolution.
1652 :param n_filters: Number of locally connected filters per pre-synaptic region.
1653 :param nu: Learning rate for both pre- and post-synaptic events. It also
1654 accepts a pair of tensors to individualize learning rates of each neuron.
1655 In this case, their shape should be the same size as the connection weights.
1656 :param reduction: Method for reducing parameter updates along the minibatch dimension.
1657 :param weight_decay: Constant multiple to decay weights by on each iteration.
1658 :param w_dtype: Data type for :code:`w` tensor
1659 Keyword arguments:
1660 :param LearningRule update_rule: Modifies connection parameters according to some rule.
1661 :param torch.Tensor w: Strengths of synapses.
1662 :param torch.Tensor b: Target population bias.
1663 :param float wmin: Minimum allowed value on the connection weights.
1664 :param float wmax: Maximum allowed value on the connection weights.
1665 :param float norm: Total weight per target neuron normalization constant.
1666 """
1667
1668 super().__init__(source, target, nu, reduction, weight_decay, **kwargs)
1669
1670 kernel_size = _pair(kernel_size)
1671 stride = _pair(stride)
1672
1673 self.kernel_size = kernel_size
1674 self.stride = stride
1675 self.n_filters = n_filters
1676
1677 self.in_channels, input_height, input_width = (
1678 source.shape[0],
1679 source.shape[1],
1680 source.shape[2],

Callers 1

loc2d_mnist.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected