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). |
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), 'cpt' (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
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 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 | |