Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move reward modulation inputs to GPU #406

Merged
merged 1 commit into from
Aug 16, 2020
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