Skip to content

Commit 644244c

Browse files
Merge pull request BindsNET#406 from BindsNET/hananel
Move reward modulation inputs to GPU
2 parents 0743296 + c4ce5a8 commit 644244c

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

bindsnet/learning/learning.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
)
1414
from ..utils import im2col_indices
1515

16+
1617
class LearningRule(ABC):
1718
# language=rst
1819
"""
@@ -547,11 +548,17 @@ def _connection_update(self, **kwargs) -> None:
547548

548549
# Initialize eligibility, P^+, and P^-.
549550
if not hasattr(self, "p_plus"):
550-
self.p_plus = torch.zeros(batch_size, *self.source.shape)
551+
self.p_plus = torch.zeros(
552+
batch_size, *self.source.shape, device=self.source.s.device
553+
)
551554
if not hasattr(self, "p_minus"):
552-
self.p_minus = torch.zeros(batch_size, *self.target.shape)
555+
self.p_minus = torch.zeros(
556+
batch_size, *self.target.shape, device=self.target.s.device
557+
)
553558
if not hasattr(self, "eligibility"):
554-
self.eligibility = torch.zeros(batch_size, *self.connection.w.shape)
559+
self.eligibility = torch.zeros(
560+
batch_size, *self.connection.w.shape, device=self.connection.w.device
561+
)
555562

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

0 commit comments

Comments
 (0)