Skip to content

Commit

Permalink
Merge pull request #41 from genn-team/small_fixes
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
neworderofjamie authored Sep 18, 2019
2 parents eee732f + c10903f commit 0774e22
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
29 changes: 19 additions & 10 deletions pynn_genn/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def build_genn_model(self, defs, native_params, init_vals,
# and, without the prefix, it is in parameters
if not param.is_homogeneous and field_name.startswith(prefix) and field_name_no_prefix in param_name_types:
# Add it to variables
var_name_types.append((field_name,
var_name_types.append((field_name_no_prefix,
param_name_types[field_name_no_prefix]))

# Remove from parameters
Expand Down Expand Up @@ -110,10 +110,10 @@ def build_genn_model(self, defs, native_params, init_vals,
if not ini.is_homogeneous:
# Add it to variables
var_name_types.append(
(param_name, param_name_types[param_name_no_prefix]))
(param_name_no_prefix, param_name_types[param_name_no_prefix]))

# Remove from parameters
del param_name_types[field_name_no_prefix]
del param_name_types[param_name_no_prefix]

# Set parameter names in defs
genn_defs["param_names"] = list(param_name_types.keys())
Expand Down Expand Up @@ -259,13 +259,22 @@ def build_genn_wum(self, conn_params, init_vals):
wum_params = {n: conn_params[n][0]
for n in genn_defs["param_names"]}

# Convert variables to arrays with correct data type
wum_init = {n: conn_params[n].astype(genn_to_numpy_types[t]
if t in genn_to_numpy_types
else np.float32,
copy=False)
for n, t in iteritems(vars)}

# Loop through GeNN variables
wum_init = {}
for n, t in iteritems(vars):
# Get type to use for variable
var_type = (genn_to_numpy_types[t] if t in genn_to_numpy_types
else np.float32)

# If this variable is set by connection parameters, use these as initial values
if n in conn_params:
wum_init[n] = conn_params[n].astype(var_type, copy=False)
# Otherwise, if there is a default in the model, use that
elif n in self.default_initial_values:
wum_init[n] = self.default_initial_values[n]
else:
raise Exception("Variable '{}' not "
"correctly initialised".format(n))
# Zero all presynaptic variables
# **TODO** other means of initialisation
wum_pre_init = (None
Expand Down
22 changes: 11 additions & 11 deletions pynn_genn/standardmodels/synapses.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ class TsodyksMarkramSynapse(synapses.TsodyksMarkramSynapse, GeNNStandardSynapseT
"z" : 0.0
})

mutable_vars = set(["x", "y", "z", "u"])

wum_defs = {
"sim_code" : """
scalar deltaST = $(t) - $(sT_pre);
$(z) *= exp( -deltaST / $(tauRec) );
$(z) += $(y) * ( exp( -deltaST / $(tauPsc) ) -
exp( -deltaST / $(tauRec) ) ) / ( ( $(tauPsc) / $(tauRec) ) - 1 );
$(y) *= exp( -deltaST / $(tauPsc) );
$(x) = 1 - $(y) - $(z);
$(u) *= exp( -deltaST / $(tauFacil) );
$(u) += $(U) * ( 1 - $(u) );
if ( $(u) > $(U) ) {
$(u) = $(U);
const scalar deltaST = $(t) - $(sT_pre);
$(z) *= exp(-deltaST / $(tauRec));
$(z) += $(y) * (exp(-deltaST / $(tauPsc)) - exp(-deltaST / $(tauRec))) / (($(tauPsc) / $(tauRec)) - 1.0);
$(y) *= exp(-deltaST / $(tauPsc));
$(x) = 1.0 - $(y) - $(z);
$(u) *= exp(-deltaST / $(tauFacil));
$(u) += $(U) * (1.0 - $(u));
if ($(u) > $(U)) {
$(u) = $(U);
}
$(y) += $(x) * $(u);
$(addToInSyn, $(g) * $(x) * $(u));
$(updatelinsyn);
""",
"vars" : {
"U": "scalar", # asymptotic value of probability of release
Expand Down

0 comments on commit 0774e22

Please sign in to comment.