Skip to content

Commit

Permalink
Merge pull request #540 from navidkashi/issue-539_fix
Browse files Browse the repository at this point in the history
Fix calling to NoneType object
  • Loading branch information
Hananel-Hazan authored Feb 13, 2022
2 parents 1778ddb + 5123a23 commit b850dd1
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bindsnet/datasets/spoken_mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions bindsnet/network/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand Down
5 changes: 1 addition & 4 deletions bindsnet/pipeline/environment_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion examples/mnist/conv3d_MNIST.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion examples/mnist/conv_mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion examples/tensorboard/tensorboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down

0 comments on commit b850dd1

Please sign in to comment.