From 51618a723abf178af0176cd8ecd80a76b06fbe85 Mon Sep 17 00:00:00 2001 From: Felix Bauer Date: Wed, 30 Aug 2023 14:04:38 +0200 Subject: [PATCH 1/2] Correct test whether subtract value is None --- sinabs/activation/reset_mechanism.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sinabs/activation/reset_mechanism.py b/sinabs/activation/reset_mechanism.py index 05aa18de..4f8886b2 100644 --- a/sinabs/activation/reset_mechanism.py +++ b/sinabs/activation/reset_mechanism.py @@ -39,7 +39,7 @@ class MembraneSubtract: def __call__(self, spikes, state, threshold): new_state = state.copy() - if self.subtract_value: + if self.subtract_value is not None: new_state["v_mem"] = new_state["v_mem"] - spikes * self.subtract_value else: new_state["v_mem"] = new_state["v_mem"] - spikes * threshold From ba9a157a9e488ebb56872a0630746f642a32af51 Mon Sep 17 00:00:00 2001 From: Felix Bauer Date: Wed, 30 Aug 2023 17:07:48 +0200 Subject: [PATCH 2/2] Add unit test to ensure that subract value of MembraneSubtract can be a tensor --- tests/test_activations.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test_activations.py b/tests/test_activations.py index 2c836f7f..2487c6c4 100644 --- a/tests/test_activations.py +++ b/tests/test_activations.py @@ -20,6 +20,12 @@ torch.tensor([1.0, 0.0]), torch.tensor([1.5, 0.3]), ), + ( + SingleSpike, + MembraneSubtract(subtract_value=torch.tensor([0.9, 1.1])), + torch.tensor([1.0, 0.0]), + torch.tensor([1.6, 0.3]), + ), ( SingleSpike, MembraneReset(),