AdaptiveThresholdMixin

class AdaptiveThresholdMixin(data: Tensor, batch_reduction: Callable[[Tensor, int | tuple[int, ...]], Tensor] | None = None)[source]

Bases: object

Mixin for neurons with adaptative thresholds.

Parameters:

Note

batch_reduction can be one of the functions in PyTorch including but not limited to torch.sum(), torch.mean(), and torch.amax(). A custom function with similar behavior can also be passed in. Like with the included function, it should not keep the original dimensions by default.

property threshold_adaptation: Tensor

Threshold adaptations.

If the value the setter attempts to assign has the same shape but with an additonal leading dimension, it will assume that is an unreduced batch dimension and reduce it.

Parameters:

value (torch.Tensor) – new threshold adaptations.

Returns:

present threshold adaptations.

Return type:

torch.Tensor