| 573 | |
| 574 | |
| 575 | class Weight(AbstractFeature): |
| 576 | def __init__( |
| 577 | self, |
| 578 | name: str, |
| 579 | value: Union[torch.Tensor, float, int] = None, |
| 580 | value_dtype: torch.dtype = torch.float32, |
| 581 | range: Optional[Sequence[float]] = None, |
| 582 | norm: Optional[Union[torch.Tensor, float, int]] = None, |
| 583 | norm_frequency: Optional[str] = "sample", |
| 584 | learning_rule: Optional[bindsnet.learning.LearningRule] = None, |
| 585 | nu: Optional[Union[list, tuple]] = None, |
| 586 | reduction: Optional[callable] = None, |
| 587 | enforce_polarity: Optional[bool] = False, |
| 588 | decay: float = 0.0, |
| 589 | sparse: Optional[bool] = False, |
| 590 | batch_size: int = 1, |
| 591 | ) -> None: |
| 592 | # language=rst |
| 593 | """ |
| 594 | Multiplies signals by scalars |
| 595 | :param name: Name of the feature |
| 596 | :param value: Values to scale signals by |
| 597 | :param value_dtype: Data type for :code:`value` tensor |
| 598 | :param range: Range of acceptable values for the :code:`value` parameter |
| 599 | :param norm: Value which all values in :code:`value` will sum to. Normalization of values occurs after each sample |
| 600 | and after the value has been updated by the learning rule (if there is one) |
| 601 | :param norm_frequency: How often to normalize weights: |
| 602 | * 'sample': weights normalized after each sample |
| 603 | * 'time step': weights normalized after each time step |
| 604 | :param learning_rule: Rule which will modify the :code:`value` after each sample |
| 605 | :param nu: Learning rate for the learning rule |
| 606 | :param reduction: Method for reducing parameter updates along the minibatch |
| 607 | dimension |
| 608 | :param enforce_polarity: Will prevent synapses from changing signs if :code:`True` |
| 609 | :param decay: Constant multiple to decay weights by on each iteration |
| 610 | :param sparse: Should :code:`value` parameter be sparse tensor or not |
| 611 | :param batch_size: Mini-batch size. |
| 612 | """ |
| 613 | |
| 614 | self.norm_frequency = norm_frequency |
| 615 | self.enforce_polarity = enforce_polarity |
| 616 | super().__init__( |
| 617 | name=name, |
| 618 | value=value, |
| 619 | value_dtype=value_dtype, |
| 620 | range=[-torch.inf, +torch.inf] if range is None else range, |
| 621 | norm=norm, |
| 622 | learning_rule=learning_rule, |
| 623 | nu=nu, |
| 624 | reduction=reduction, |
| 625 | decay=decay, |
| 626 | sparse=sparse, |
| 627 | batch_size=batch_size, |
| 628 | ) |
| 629 | |
| 630 | def reset_state_variables(self) -> None: |
| 631 | pass |
| 632 |
no outgoing calls
no test coverage detected