pgms
pgms
¤
fully_factorized(num_variables, input_layer='categorical', input_params=None, input_layer_kwargs=None)
¤
Construct a circuit encoding a fully-factorized model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_variables
|
int
|
The number of variables. |
required |
input_layer
|
str
|
The input layer to use for the factors. It can be 'categorical', 'binomial' or 'gaussian'. Defaults to 'categorical'. |
'categorical'
|
input_params
|
Mapping[str, Parameterization] | None
|
A dictionary mapping each name of a parameter of the input layer to its parameterization. If it is None, then the default parameterization of the chosen input layer will be chosen. |
None
|
input_layer_kwargs
|
Mapping[str, Any] | list[Mapping[str, Any]] | None
|
Additional optional arguments to pass when constructing input layers. If it is a dictionary, then it is interpreted as kwargs passed to all input layers constructors. If it is a list of dictionaries, then it must contain as many dictionaries as the number of variables, and each dictionary is interpreted as kwargs passed to each input layer constructor (in the order given by range(num_variables)). |
None
|
Source code in cirkit/templates/pgms.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 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 | |
hmm(ordering, input_layer='categorical', num_latent_states=1, input_params=None, input_layer_kwargs=None, weight_param=None)
¤
Construct a symbolic circuit mimicking a hidden markov model (HMM) of a given variable ordering. Product Layers are of type HadamardLayer, and sum layers are of type SumLayer. Note that the HMM constructed is inhomogeneous, i.e., the emission probability tables and the transition probability tables are not shared between time steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ordering
|
Sequence[int]
|
The input order of variables of the HMM. |
required |
input_layer
|
str
|
The input layer to use for the factors. It can be 'categorical', 'binomial' or 'gaussian'. Defaults to 'categorical'. |
'categorical'
|
num_latent_states
|
int
|
The number of states the latent variables can assume or, equivalently, the number of sum units per sum layer. |
1
|
input_params
|
Mapping[str, Parameterization] | None
|
A dictionary mapping each name of a parameter of the input layer to its parameterization. If it is None, then the default parameterization of the chosen input layer will be chosen. |
None
|
input_layer_kwargs
|
Mapping[str, Any] | list[Mapping[str, Any]] | None
|
Additional optional arguments to pass when constructing input layers. If it is a dictionary, then it is interpreted as kwargs passed to all input layers constructors. If it is a list of dictionaries, then it must contain as many dictionaries as the number of variables, and each dictionary is interpreted as kwargs passed to each input layer constructor (in the order given by range(num_variables)). |
None
|
weight_param
|
Parameterization | None
|
The parameterization to use for the weight coefficients. If None, then it defaults to using a softmax parameterization for the transition probability tables. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Circuit |
Circuit
|
A symbolic circuit encoding an HMM. |
Raises:
| Type | Description |
|---|---|
ValueError
|
order must consists of consistent numbers, starting from 0. |
Source code in cirkit/templates/pgms.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |