data_modalities
data_modalities
¤
image_data(image_shape, region_graph='quad-graph', *, input_layer, num_input_units, sum_product_layer, num_sum_units, num_classes=1, input_params=None, sum_weight_param=None, use_mixing_weights=True)
¤
Constructs a symbolic circuit whose structure is tailored for image data sets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_shape
|
tuple[int, int, int]
|
The image shape (C, H, W), where C is the number of channels, H is the height of the images, and W is their width. |
required |
region_graph
|
str
|
The name of the region graph to use. It can be one of the following: 'quad-tree-2' (the Quad-Tree with two splits per region node), 'quad-tree-4' (the Quad-Tree with four splits per region node), 'quad-graph' (the Quad-Graph region graph), 'random-binary-tree' (the random binary tree on flattened image pixels), 'poon-domingos' (the Poon-Domingos architecture). |
'quad-graph'
|
input_layer
|
str
|
The name of the input layer. It can be one of the following: 'categorical' (encoding a Categorical distribution over pixel channel values), 'binomial' (encoding a Binomial distribution over pixel channel values), 'embedding' (encoding an Embedding vector over pixel channel values), 'gaussian' (encoding a Gaussian distribution over pixel channel values). |
required |
num_input_units
|
int
|
The number of input units per input layer. |
required |
sum_product_layer
|
str
|
The name of the sum-product inner layer. It can be one of the following: 'cp' (the canonical decomposition layer, consisting of dense layers followed by a hadamard product layer), 'cp-t' (the transposed canonical decomposition layer, consisting of a hadamard product layer followed by a single dense layer), 'tucker' (the Tucker decomposition layer, consisting of a kronecker product layer followed by a single dense layer). |
required |
num_classes
|
int
|
The number of output classes (default=1). |
1
|
num_sum_units
|
int
|
The number of sum units in each sum layer, i.e., either dense or mixing layer. |
required |
input_params
|
dict[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
|
sum_weight_param
|
Parameterization | None
|
The parameterization to use for sum layers parameters. If it None, then a softmax parameterization of the sum weights will be used. |
None
|
use_mixing_weights
|
bool
|
Whether to parameterize sum layers having arity > 1 in a way such that they compute a linear combinations of the input vectors, instead of computing a matrix-vector product where the vector is the concatenation of input vectors. Sum layers having this semantics are also sometimes referred to as "mixing" layers. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
Circuit |
Circuit
|
A symbolic circuit. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If one of the arguments is not one of the specified allowed ones. |
Source code in cirkit/templates/data_modalities.py
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 74 75 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 | |
tabular_data(region_graph='random-binary-tree', *, num_features=None, data=None, input_layers, num_input_units, sum_product_layer, num_sum_units, num_classes=1, sum_weight_param=None, use_mixing_weights=True)
¤
Constructs a symbolic circuit whose structure is tailored for tabular data sets, supporting either a fixed random-binary-tree or a learned Chow–Liu tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
region_graph
|
str
|
Which region graph to use.
- |
'random-binary-tree'
|
num_features
|
int | None
|
Number of features (columns) in the dataset.
Required if |
None
|
data
|
Tensor | None
|
A Torch tensor of shape |
None
|
input_layers
|
dict | list[dict]
|
Which per-feature distribution to use.
The provided dictionaries should be of the following form:
{
'name': |
required |
num_input_units
|
int
|
Number of parallel input units (e.g. mixtures/components) per feature. |
required |
sum_product_layer
|
str
|
Which inner sum/product decomposition to use. E.g. |
required |
num_sum_units
|
int
|
Number of sum (or mixing) units in each sum layer. |
required |
num_classes
|
int
|
Number of output classes (or root-layer mixtures). Often 1 for pure density estimation. |
1
|
sum_weight_param
|
Parameterization | None
|
If provided, a |
None
|
use_mixing_weights
|
bool
|
Whether to use “mixing” sum layers (i.e. learn a linear combination of child outputs) for nodes of arity >1. If False, falls back to a matrix-vector product. |
True
|
Returns:
| Type | Description |
|---|---|
Circuit
|
Circuit A fully-specified sum-product circuit over the given region graph with the chosen input distributions and inner decomposition layer. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in cirkit/templates/data_modalities.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |