Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions bindsnet/learning/learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
)
from ..utils import im2col_indices


class LearningRule(ABC):
# language=rst
"""
Expand Down Expand Up @@ -547,11 +548,17 @@ def _connection_update(self, **kwargs) -> None:

# Initialize eligibility, P^+, and P^-.
if not hasattr(self, "p_plus"):
self.p_plus = torch.zeros(batch_size, *self.source.shape)
self.p_plus = torch.zeros(
batch_size, *self.source.shape, device=self.source.s.device
)
if not hasattr(self, "p_minus"):
self.p_minus = torch.zeros(batch_size, *self.target.shape)
self.p_minus = torch.zeros(
batch_size, *self.target.shape, device=self.target.s.device
)
if not hasattr(self, "eligibility"):
self.eligibility = torch.zeros(batch_size, *self.connection.w.shape)
self.eligibility = torch.zeros(
batch_size, *self.connection.w.shape, device=self.connection.w.device
)

# Reshape pre- and post-synaptic spikes.
source_s = self.source.s.view(batch_size, -1).float()
Expand Down