ZeroInit

Contents

ZeroInit#

class braintools.init.ZeroInit(unit=Unit('1'))#

Zero initialization.

Special case of constant initialization that initializes all values to zero. Useful for initializing connections that start with no synaptic weight.

Parameters:

unit (Unit) – The unit of the zero values (default: unitless).

Examples

>>> import numpy as np
>>> import brainunit as u
>>> from braintools.init import ZeroInit
>>>
>>> # Create zero weights with siemens unit
>>> init = ZeroInit(u.siemens)
>>> weights = init(100)
>>> assert np.all(weights == 0.0 * u.siemens)
>>>
>>> # Create unitless zero weights
>>> init = ZeroInit()
>>> weights = init((10, 20))
>>> assert np.all(weights == 0.0)