Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation fails when using batch sizes larger than 1 in combination with is_prev_post_spike_time_required=True #564

Closed
FabianSchubert opened this issue Feb 6, 2023 · 0 comments · Fixed by #565
Labels

Comments

@FabianSchubert
Copy link
Contributor

If the model contains a weight update class that uses
is_prev_post_spike_time_required=True and model.batch_size is set to any number larger than 1, building the model fails with the error class "MergedNeuronPrevSpikeTimeUpdateGroup0" has no member "numNeurons"
A code example (any value of NBATCH larger 1 produces the error):

import numpy as np
from pygenn.genn_model import (GeNNModel,
                               create_custom_weight_update_class,
                               init_var)

NBATCH = 10
R_TARG = 1.0

T = 100.0
DT = 0.1
NT = int(T/DT)

cs_wu = create_custom_weight_update_class(
        "cs_wu_class",
        param_names=["mu"],
        var_name_types=[("g", "scalar")],
        sim_code="$(addToInSyn, $(g));",
        learn_post_code=f"""
            $(g) += $(mu)*(
                {R_TARG}*($(t)-$(prev_sT_post))
                - 1.0
            );
        """,
        is_prev_post_spike_time_required=True
        )

model = GeNNModel("float", "test")
model.batch_size = NBATCH

poiss_pop = model.add_neuron_population(
        "poiss_pop",
        10, "Poisson",
        {"trefract": 0.0,
         "tspike":0.0,
         "Vspike":1.0,
         "Vrest":0.0},
        {"V":0.0, "spikeTime": 0.0}
        )

lif_pop = model.add_neuron_population(
        "lif_pop",
        10, "LIF",
        {"C": 1.0,
        "Ioffset": 0.0,
        "TauM": 1.0,
        "TauRefrac": 0.0,
        "Vreset": 0.0,
        "Vrest": 0.0,
        "Vthresh": 1.0},
        {"RefracTime": 0.0, "V": 0.0}
        )

syn_pop = model.add_synapse_population(
        "syn_pop", "DENSE_INDIVIDUALG", 0,
        "poiss_pop", "lif_pop",
        cs_wu, {"mu": 0.01},
        {"g": init_var("Uniform",{"min":0.0,"max":0.0})},
        {}, {},
        "DeltaCurr", {}, {})

model.build()

poiss_pop.set_extra_global_param("firingProb", np.random.rand(10))
poiss_pop.set_extra_global_param("offset", 0)

model.load()

for t in range(NT):
    model.step_time()

print("done")
@neworderofjamie neworderofjamie added this to the GeNN 4.9.0 milestone Feb 6, 2023
@neworderofjamie neworderofjamie modified the milestones: GeNN 4.9.0, GeNN 4.8.1 Mar 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants