ANNarchy 5.0.0
  • ANNarchy
  • Installation
  • Tutorial
  • Manual
  • Notebooks
  • Reference

  • ANNarchy
  • Core components
    • Network
    • Population
    • Projection
    • Monitor
    • PopulationView
    • Dendrite
  • Neuron and Synapse models
    • Neuron
    • Synapse
    • Parameter
    • Variable
    • Creating
    • Pruning
    • Constant
  • Neuron models
    • LeakyIntegrator
    • Izhikevich
    • IF_curr_exp
    • IF_cond_exp
    • IF_curr_alpha
    • IF_cond_alpha
    • HH_cond_exp
    • EIF_cond_alpha_isfa_ista
    • EIF_cond_exp_isfa_ista
  • Synapse models
    • Hebb
    • Oja
    • IBCM
    • STP
    • STDP
  • Inputs
    • InputArray
    • TimedArray
    • PoissonPopulation
    • TimedPoissonPopulation
    • SpikeSourceArray
    • HomogeneousCorrelatedSpikeTrains
    • CurrentInjection
    • DecodingProjection
    • ImagePopulation
    • VideoPopulation
  • Random Distributions
    • Uniform
    • DiscreteUniform
    • Normal
    • LogNormal
    • Exponential
    • Gamma
    • Binomial
  • Functions
    • add_function
    • functions
  • Callbacks
    • every
  • Utilities
    • report
    • timeit
    • sparse_random_matrix
    • sparse_delays_from_weights
    • magic_network
  • Convolution
    • Convolution
    • Pooling
    • Transpose
    • Copy
  • BOLD monitoring
    • BoldMonitor
    • BoldModel
    • balloon_RN
    • balloon_RL
    • balloon_CN
    • balloon_CL
    • balloon_maith2021
    • balloon_two_inputs
  • Tensorboard logging
    • Logger
  • ANN-to-SNN conversion
    • ANNtoSNNConverter
  • DEPRECATED Top-level API
    • setup
    • compile
    • clear
    • reset
    • set_seed
    • get_population
    • get_projection
    • populations
    • projections
    • monitors
    • simulate
    • simulate_until
    • step
    • enable_learning
    • disable_learning
    • get_time
    • set_time
    • get_current_step
    • set_current_step
    • dt
    • save
    • load
    • save_parameters
    • load_parameters
    • callbacks_enabled
    • disable_callbacks
    • enable_callbacks
    • clear_all_callbacks

On this page

  • Constant
    • Parameters
    • Attributes
    • Methods
      • set

Constant

Constant(self, name, value, net_id=0)

Constant parameter that can be used by all neurons and synapses.

The class Constant derives from float, so any legal operation on floats (addition, multiplication) can be used, but it returns a float.

If a Neuron/Synapse already defines a parameter with the same name, the constant will not be visible.

The constant can be declared at the global level, usually before the neuron/synapse definition:

tau = ann.Constant('tau', 20)
factor = ann.Constant('factor', 0.1)
real_tau = ann.Constant('real_tau', tau*factor)

neuron = ann.Neuron(
    equations=[
        'real_tau * dr/dt + r = 1.0'
    ]
)

net = ann.Network()
net.create(10, neuron)
net.compile()

The value of the constant can be changed anytime with the set() method.

tau.set(30.0)

If tau was defined at the global level, ALL networks using that constant will see the change. If you want the change to impact only one network, you should first retrieve the local Constant instance from the network:

tau = net.get_constant('tau')
tau.set(30.0)

Assignments will have no effect (e.g. tau = 10.0 creates a new float and erases the Constant object).

The value of constants defined as combination of other constants (real_tau) is not updated if the value of these constants changes (changing tau with tau.set(10.0) will not modify the value of real_tau).

Parameters

Name Type Description Default
name str name of the constant (unique), which can be used in equations. required
value float the value of the constant, which must be a float, or a combination of Constants. required

Attributes

Name Description
name Name.
value Value.

Methods

Name Description
set Changes the value of the constant.

set

set(value)

Changes the value of the constant.

If the constant was declared globally, this impacts all networks. Call Network.get_constant(name) if you want to impact a single network.

Parameters

Name Type Description Default
value float Value. required
Pruning
LeakyIntegrator
 

Copyright Julien Vitay, Helge Ülo Dinkelbach, Fred Hamker