From 623fd3d3068be0fb8b2e97c5247daffa8f55a432 Mon Sep 17 00:00:00 2001 From: Navid Kashi Date: Mon, 7 Feb 2022 09:04:10 +0100 Subject: [PATCH 1/2] fix calling to NoneType object --- bindsnet/pipeline/environment_pipeline.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bindsnet/pipeline/environment_pipeline.py b/bindsnet/pipeline/environment_pipeline.py index 119e22bd..9f12a477 100644 --- a/bindsnet/pipeline/environment_pipeline.py +++ b/bindsnet/pipeline/environment_pipeline.py @@ -252,10 +252,7 @@ def step_( obs = obs.unsqueeze(0).unsqueeze(0) obs_shape = torch.tensor([1] * len(obs.shape[1:]), device=self.device) inputs = { - k: self.encoding( - obs.repeat(self.time, *obs_shape).to(self.device), - device=self.device, - ) + k: obs.repeat(self.time, *obs_shape).to(self.device) for k in self.inputs } else: From 5123a23c3b78a2f771ab06e05aaad80b8ad8864f Mon Sep 17 00:00:00 2001 From: Hananel Hazan Date: Sun, 13 Feb 2022 17:28:49 -0500 Subject: [PATCH 2/2] Call NoneType object! #539 --- bindsnet/datasets/spoken_mnist.py | 2 +- bindsnet/network/nodes.py | 10 +++++----- examples/mnist/conv3d_MNIST.py | 2 +- examples/mnist/conv_mnist.py | 2 +- examples/tensorboard/tensorboard.py | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bindsnet/datasets/spoken_mnist.py b/bindsnet/datasets/spoken_mnist.py index 7a86fee6..b8c6f544 100644 --- a/bindsnet/datasets/spoken_mnist.py +++ b/bindsnet/datasets/spoken_mnist.py @@ -250,7 +250,7 @@ def process_data( # Fast Fourier Transform and Power Spectrum NFFT = 512 mag_frames = np.absolute(np.fft.rfft(frames, NFFT)) # Magnitude of the FFT - pow_frames = (1.0 / NFFT) * (mag_frames ** 2) # Power Spectrum + pow_frames = (1.0 / NFFT) * (mag_frames**2) # Power Spectrum # Log filter banks nfilt = 40 diff --git a/bindsnet/network/nodes.py b/bindsnet/network/nodes.py index c99b42cf..cf8b709c 100644 --- a/bindsnet/network/nodes.py +++ b/bindsnet/network/nodes.py @@ -1212,8 +1212,8 @@ def __init__( self.r = torch.rand(n) self.a = 0.02 * torch.ones(n) self.b = 0.2 * torch.ones(n) - self.c = -65.0 + 15 * (self.r ** 2) - self.d = 8 - 6 * (self.r ** 2) + self.c = -65.0 + 15 * (self.r**2) + self.d = 8 - 6 * (self.r**2) self.S = 0.5 * torch.rand(n, n) self.excitatory = torch.ones(n).byte() @@ -1282,8 +1282,8 @@ def forward(self, x: torch.Tensor) -> None: ) # Apply v and u updates. - self.v += self.dt * 0.5 * (0.04 * self.v ** 2 + 5 * self.v + 140 - self.u + x) - self.v += self.dt * 0.5 * (0.04 * self.v ** 2 + 5 * self.v + 140 - self.u + x) + self.v += self.dt * 0.5 * (0.04 * self.v**2 + 5 * self.v + 140 - self.u + x) + self.v += self.dt * 0.5 * (0.04 * self.v**2 + 5 * self.v + 140 - self.u + x) self.u += self.dt * self.a * (self.b * self.v - self.u) # Voltage clipping to lower bound. @@ -1518,7 +1518,7 @@ def set_batch_size(self, batch_size) -> None: def AlphaKernel(self, dt): t = torch.arange(0, self.res_window_size, dt) - kernelVec = (1 / (self.tau ** 2)) * t * torch.exp(-t / self.tau) + kernelVec = (1 / (self.tau**2)) * t * torch.exp(-t / self.tau) return torch.flip(kernelVec, [0]) def AlphaKernelSLAYER(self, dt): diff --git a/examples/mnist/conv3d_MNIST.py b/examples/mnist/conv3d_MNIST.py index be0b280e..8a8e4c50 100644 --- a/examples/mnist/conv3d_MNIST.py +++ b/examples/mnist/conv3d_MNIST.py @@ -94,7 +94,7 @@ kernel_size=kernel_size, stride=stride, update_rule=PostPre, - norm=0.4 * kernel_size ** 3, + norm=0.4 * kernel_size**3, nu=[1e-4, 1e-2], wmax=1.0, ) diff --git a/examples/mnist/conv_mnist.py b/examples/mnist/conv_mnist.py index a23f0b4b..f91fd5c6 100644 --- a/examples/mnist/conv_mnist.py +++ b/examples/mnist/conv_mnist.py @@ -98,7 +98,7 @@ kernel_size=kernel_size, stride=stride, update_rule=PostPre, - norm=0.4 * kernel_size ** 2, + norm=0.4 * kernel_size**2, nu=[1e-4, 1e-2], wmax=1.0, ) diff --git a/examples/tensorboard/tensorboard.py b/examples/tensorboard/tensorboard.py index 127b1e52..a35a7e8d 100644 --- a/examples/tensorboard/tensorboard.py +++ b/examples/tensorboard/tensorboard.py @@ -87,7 +87,7 @@ kernel_size=kernel_size, stride=stride, update_rule=PostPre, - norm=0.4 * kernel_size ** 2, + norm=0.4 * kernel_size**2, nu=[1e-4, 1e-2], wmax=1.0, )