i = torch.bernoulli(1 - self.sparsity * torch.ones(*source.shape, *target.shape))
v = self.wmin + (self.wmax - self.wmin) * torch.rand(*source.shape, *target.shape)[i.byte()]
self.w = torch.sparse.FloatTensor(i.nonzero().t(), v)
elif self.w is not None:
assert self.w.is_sparse, "Weight matrix is not sparse (see torch.sparse module)"
def compute(self, s: torch.Tensor) -> torch.Tensor:
After Change
self.w = torch.sparse.FloatTensor(i.nonzero().t(), v)
elif self.w is not None and self.sparsity is None:
assert self.w.is_sparse, "Weight matrix is not sparse (see torch.sparse module)"
if self.wmin != -np.inf or self.wmax != np.inf:
self.w = torch.clamp(self.w, self.wmin, self.wmax)
def compute(self, s: torch.Tensor) -> torch.Tensor:
// language=rst
Compute convolutional pre-activations given spikes using layer weights.