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

Method __init__

bindsnet/network/topology_features.py:468–505  ·  view source on GitHub ↗

Boolean mask which determines whether or not signals are allowed to traverse certain synapses. :param name: Name of the feature :param value: Boolean mask. :code:`True` means a signal can pass, :code:`False` means the synapse is impassable :param sparse: Should :code

(
        self,
        name: str,
        value: Union[torch.Tensor, float, int] = None,
        sparse: Optional[bool] = False,
        batch_size: int = 1,
    )

Source from the content-addressed store, hash-verified

466
467class Mask(AbstractFeature):
468 def __init__(
469 self,
470 name: str,
471 value: Union[torch.Tensor, float, int] = None,
472 sparse: Optional[bool] = False,
473 batch_size: int = 1,
474 ) -> None:
475 # language=rst
476 """
477 Boolean mask which determines whether or not signals are allowed to traverse certain synapses.
478 :param name: Name of the feature
479 :param value: Boolean mask. :code:`True` means a signal can pass, :code:`False` means the synapse is impassable
480 :param sparse: Should :code:`value` parameter be sparse tensor or not
481 :param batch_size: Mini-batch size.
482 """
483
484 ### Assertions ###
485 if isinstance(value, torch.Tensor):
486 assert (
487 value.dtype == torch.bool
488 ), "Mask must be of type bool, not {}".format(value.dtype)
489 elif value is not None:
490 assert isinstance(value, bool), "Mask must be of type bool, not {}".format(
491 value.dtype
492 )
493
494 # Send boolean to tensor (priming wont work if it's not a tensor)
495 value = torch.tensor(value)
496
497 super().__init__(
498 name=name,
499 value=value,
500 value_dtype=torch.bool,
501 sparse=sparse,
502 batch_size=batch_size,
503 )
504 self.name = name
505 self.value = value
506
507 def compute(self, conn_spikes) -> torch.Tensor:
508 return conn_spikes * self.value

Callers 11

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected