Skip to content

Commit 953d163

Browse files
Merge pull request #400 from BindsNET/hananel
Configuration update and small cosmetic changes
2 parents 8df1d9e + 8f80f0b commit 953d163

File tree

8 files changed

+30
-24
lines changed

8 files changed

+30
-24
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ repos:
33
rev: master
44
hooks:
55
- id: black
6-
language_version: python3.8
6+
language_version: python3.8

Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ FROM arwineap/docker-ubuntu-python3.6
33
RUN apt-get update
44

55
# Install latest version of python3
6-
RUN apt install -y python3.6
6+
RUN apt install -y python3.8
77
RUN pip install --upgrade setuptools
8-
RUN apt-get install -y python3.6-dev build-essential
8+
RUN apt-get install -y python3.8-dev build-essential
99
RUN apt-get install -y libblas-dev libatlas-base-dev
1010

1111
# Upgrade pip
@@ -15,14 +15,11 @@ RUN apt-get install -y python3-tk
1515
RUN apt install -y libglib2.0-0
1616
RUN apt install -y libsm6 libxext6
1717

18-
# Install bindsnet and dependencies
19-
RUN pip install -U bindsnet
20-
2118
# Install git
2219
RUN apt-get install -y git-core
2320

2421
# Install vim
25-
RUN apt install -y vim
22+
RUN apt install -y vim
2623
RUN pip install jupyter -U && pip install jupyterlab
2724

2825
# Bind python3.6 to python
@@ -36,3 +33,5 @@ RUN mkdir working
3633
RUN chmod 777 \/working
3734
ENTRYPOINT ["/working"]
3835

36+
# Install bindsnet and dependencies
37+
RUN pip install -U git+https://github.com/BindsNET/bindsnet.git

bindsnet/analysis/plotting.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ def plot_voltages(
588588
.cpu()
589589
.numpy()[
590590
time[0] : time[1],
591-
n_neurons[v[0]][0]: n_neurons[v[0]][1],
591+
n_neurons[v[0]][0] : n_neurons[v[0]][1],
592592
]
593593
)
594594
)
@@ -608,7 +608,7 @@ def plot_voltages(
608608
.cpu()
609609
.numpy()[
610610
time[0] : time[1],
611-
n_neurons[v[0]][0] : n_neurons[v[0]][1],
611+
n_neurons[v[0]][0] : n_neurons[v[0]][1],
612612
]
613613
.T,
614614
cmap=cmap,
@@ -685,7 +685,7 @@ def plot_voltages(
685685
v[1]
686686
.cpu()
687687
.numpy()[
688-
time[0] : time[1], n_neurons[v[0]][0] : n_neurons[v[0]][1]
688+
time[0] : time[1], n_neurons[v[0]][0] : n_neurons[v[0]][1]
689689
]
690690
)
691691
if thresholds is not None and thresholds[v[0]].size() == torch.Size(

bindsnet/datasets/davis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def _check_directories(self):
204204
self._download()
205205
else:
206206
raise FileNotFoundError(
207-
f"DAVIS not found in the specified directory, download it from "
207+
"DAVIS not found in the specified directory, download it from "
208208
f"{self.DATASET_WEB} or add download=True to your call"
209209
)
210210
if not os.path.exists(os.path.join(self.imagesets_path, f"{self.subset}.txt")):

bindsnet/datasets/spoken_mnist.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ def _get_train(self, split: float = 0.8) -> Tuple[torch.Tensor, torch.Tensor]:
103103
# Serialize image data on disk for next time.
104104
torch.save((audio, labels), open(path, "wb"))
105105
else:
106-
msg = "Dataset not found on disk; specify 'download=True' to allow downloads."
106+
msg = (
107+
"Dataset not found on disk; specify 'download=True' to allow"
108+
" downloads."
109+
)
107110
raise FileNotFoundError(msg)
108111
else:
109112
if not os.path.isdir(path):
@@ -148,7 +151,10 @@ def _get_test(self, split: float = 0.8) -> Tuple[torch.Tensor, List[torch.Tensor
148151
# Serialize image data on disk for next time.
149152
torch.save((audio, labels), open(path, "wb"))
150153
else:
151-
msg = "Dataset not found on disk; specify 'download=True' to allow downloads."
154+
msg = (
155+
"Dataset not found on disk; specify 'download=True' to allow"
156+
" downloads."
157+
)
152158
raise FileNotFoundError(msg)
153159
else:
154160
if not os.path.isdir(path):

bindsnet/network/nodes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,16 +507,16 @@ def forward(self, x: torch.Tensor) -> None:
507507
self.v = self.decay * (self.v - self.rest) + self.rest
508508

509509
# Integrate inputs.
510-
x.masked_fill_(self.refrac_count > 0, 0.0) # OPTIM 2
510+
x.masked_fill_(self.refrac_count > 0, 0.0)
511+
511512
# Decrement refractory counters.
512-
self.refrac_count -= self.dt # OPTIM 1
513+
self.refrac_count -= self.dt
513514

514-
self.v += x # interlaced
515+
self.v += x # interlaced
515516

516517
# Check for spiking neurons.
517518
self.s = self.v >= self.thresh
518519

519-
520520
# Refractoriness and voltage reset.
521521
self.refrac_count.masked_fill_(self.s, self.refrac)
522522
self.v.masked_fill_(self.s, self.reset)

bindsnet/pipeline/action.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ def select_multinomial(pipeline: EnvironmentPipeline, **kwargs) -> int:
2626
output = pipeline.network.layers[output]
2727
action_space = pipeline.env.action_space
2828

29-
assert (
30-
output.n % action_space.n == 0
31-
), f"Output layer size of {output.n} is not divisible by action space size of {action_space.n}."
29+
assert output.n % action_space.n == 0, (
30+
f"Output layer size of {output.n} is not divisible by action space size of"
31+
f" {action_space.n}."
32+
)
3233

3334
pop_size = int(output.n / action_space.n)
3435
spikes = output.s

examples/mnist/reservoir.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@
6363

6464
# Sets up Gpu use
6565
if gpu and torch.cuda.is_available():
66-
device = 'cuda'
66+
device = "cuda"
6767
torch.cuda.set_device(device)
6868
# torch.set_default_tensor_type('torch.cuda.FloatTensor')
6969
else:
7070
torch.manual_seed(seed)
71-
device = 'cpu'
71+
device = "cpu"
7272
if gpu:
7373
gpu = False
7474

@@ -129,7 +129,7 @@
129129
for (i, dataPoint) in pbar:
130130
if i > n_iters:
131131
break
132-
datum = dataPoint["encoded_image"].view(int(time/dt), 1, 1, 28, 28).to(device)
132+
datum = dataPoint["encoded_image"].view(int(time / dt), 1, 1, 28, 28).to(device)
133133
label = dataPoint["label"]
134134
pbar.set_description_str("Train progress: (%d / %d)" % (i, n_iters))
135135

@@ -140,7 +140,7 @@
140140

141141
inpt_axes, inpt_ims = plot_input(
142142
dataPoint["image"].view(28, 28),
143-
datum.view(int(time/dt), 784).sum(0).view(28, 28),
143+
datum.view(int(time / dt), 784).sum(0).view(28, 28),
144144
label=label,
145145
axes=inpt_axes,
146146
ims=inpt_ims,

0 commit comments

Comments
 (0)