initializers
initializers
¤
ConstantTensorInitializer
¤
Bases: Initializer
A symbolic constant initializer, which initializes all the entries of a tensor with the same value, which can be either a scalar or a Numpy array of the same shape.
Source code in cirkit/symbolic/initializers.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
config
property
¤
value = value
instance-attribute
¤
__init__(value)
¤
Initializes a constant tensor initializer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int | float | complex | number | ndarray
|
The value used for initialization, which must be either an integer, a real number, a complex number or a Numpy array. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the initiaization value is not of the allowed types. |
Source code in cirkit/symbolic/initializers.py
50 51 52 53 54 55 56 57 58 59 60 61 62 | |
allows_shape(shape)
¤
Source code in cirkit/symbolic/initializers.py
68 69 70 71 72 73 74 75 | |
DirichletInitializer
¤
Bases: Initializer
A symbolic Dirichlet initializer, which initializes all the entries of a tensor along one axis by sampling independently from a Dirichlet distribution.
Source code in cirkit/symbolic/initializers.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
alpha = alpha
instance-attribute
¤
axis = axis
instance-attribute
¤
config
property
¤
__init__(alpha=1.0, *, axis=-1)
¤
Initializes a Dirichlet initializer, given the concentration parameters and the axis along which the sampled values will sum to one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float | list[float]
|
The concentration parameter. If it is a list, then different concentrations will be used for each random variable being sampled. |
1.0
|
axis
|
int
|
The axis along which the sampled values will sum to one. |
-1
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the concentration parameter is not positive or if it contains non-positve values. |
Source code in cirkit/symbolic/initializers.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
allows_shape(shape)
¤
Source code in cirkit/symbolic/initializers.py
156 157 158 159 160 161 162 163 | |
ElementwiseInitializer
¤
Bases: Initializer, ABC
An elementwise initializer initializes a parameter tensor by setting each entry using the same function, such as by sampling independently from a univariate distribution. Therefore, an elementwise initializer allows any parameter shape by default.
Source code in cirkit/symbolic/initializers.py
36 37 38 39 40 41 42 43 | |
allows_shape(shape)
¤
Source code in cirkit/symbolic/initializers.py
42 43 | |
Initializer
¤
Bases: ABC
The abstract symbolic initializer class. Symbolic initializers are usually assigned to TensorParameter upon their instantiation.
Source code in cirkit/symbolic/initializers.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | |
config
property
¤
__repr__()
¤
Source code in cirkit/symbolic/initializers.py
31 32 33 | |
allows_shape(shape)
abstractmethod
¤
Checks whether the given parameter shape is supported by the initializer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shape
|
tuple[int, ...]
|
The parameter shape. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the shape is supported, False otherwise. |
Source code in cirkit/symbolic/initializers.py
20 21 22 23 24 25 26 27 28 29 | |
NormalInitializer
¤
Bases: ElementwiseInitializer
A symbolic normal initializer, which initializes all the entries of a tensor by sampling independently from a univariate normal distribution.
Source code in cirkit/symbolic/initializers.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
config
property
¤
mean = mean
instance-attribute
¤
stddev = stddev
instance-attribute
¤
__init__(mean=0.0, stddev=1.0)
¤
Initializes a normal initializer, given mean and standard deviation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mean
|
float
|
The mean. |
0.0
|
stddev
|
float
|
The standard deviation. |
1.0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the standard deviation is not a positive number. |
Source code in cirkit/symbolic/initializers.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
UniformInitializer
¤
Bases: ElementwiseInitializer
A symbolic uniform initializer, which initializes all the entries of a tensor by sampling independently from a univariate uniform distribution.
Source code in cirkit/symbolic/initializers.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
a = a
instance-attribute
¤
b = b
instance-attribute
¤
config
property
¤
__init__(a=0.0, b=1.0)
¤
Initializes a uniform initializer, given minimum and maximum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
float
|
The minimum. |
0.0
|
b
|
float
|
The maximum. |
1.0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the minimum is not strictly less than the maximum. |
Source code in cirkit/symbolic/initializers.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |