siamese_dir_dataset
SiameseDirDataset
¶
Bases: LabeledDirDataset
A dataset which returns pairs of data.
This dataset reads files from a folder hierarchy like root/class(/es)/data.file. Data is returned in pairs, where the label value is 1 if the data are drawn from the same class, and 0 otherwise. One epoch is defined as the time it takes to visit every data point exactly once as the 'data_key_left'. Each data point may occur zero or many times as 'data_key_right' within the same epoch. SiameseDirDataset.split() will split by class index rather than by data instance index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root_dir |
str
|
The path to the directory containing data sorted by folders. |
required |
data_key_left |
str
|
What key to assign to the first data element in the pair. |
'x_a'
|
data_key_right |
str
|
What key to assign to the second data element in the pair. |
'x_b'
|
label_key |
str
|
What key to assign to the label values in the data dictionary. |
'y'
|
percent_matching_data |
float
|
What percentage of the time should data be paired by class (label value = 1). |
0.5
|
label_mapping |
Optional[Dict[str, Any]]
|
A dictionary defining the mapping to use. If not provided will map classes to int labels. |
None
|
file_extension |
Optional[str]
|
If provided then only files ending with the file_extension will be included. |
None
|
Source code in fastestimator/fastestimator/dataset/siamese_dir_dataset.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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
one_shot_trial
¶
Generate one-shot trial data.
The similarity should be highest between the index 0 elements of the arrays.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int
|
The number of samples to draw for computing one shot accuracy. Should be <= the number of total classes. |
required |
Returns:
Type | Description |
---|---|
List[str]
|
([class_a_instance_x, class_a_instance_x, class_a_instance_x, ...], |
List[str]
|
[class_a_instance_w, class_b_instance_y, class_c_instance_z, ...]) |
Source code in fastestimator/fastestimator/dataset/siamese_dir_dataset.py
summary
¶
Generate a summary representation of this dataset. Returns: A summary representation of this dataset.