pipeline
Pipeline
¶
A data pipeline class that takes care of data pre-processing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
train_data |
Union[None, DataSource, Scheduler[DataSource]]
|
The training data, or None if no training data is available. |
None
|
eval_data |
Union[None, DataSource, Scheduler[DataSource]]
|
The evaluation data, or None if no evaluation data is available. |
None
|
test_data |
Union[None, DataSource, Scheduler[DataSource]]
|
The testing data, or None if no evaluation data is available. |
None
|
batch_size |
Union[None, int, Scheduler[int]]
|
The batch size to be used by the pipeline. NOTE: This argument is only applicable when using a FastEstimator Dataset. |
None
|
ops |
Union[None, NumpyOp, Scheduler[NumpyOp], List[Union[NumpyOp, Scheduler[NumpyOp]]]]
|
NumpyOps to be used for pre-processing. NOTE: This argument is only applicable when using a FastEstimator Dataset. |
None
|
num_process |
Optional[int]
|
Number of CPU threads to use for data pre-processing. NOTE: This argument is only applicable when using a FastEstimator Dataset. None will default to the system CPU count. Multiprocessing can be disabled by passing 0 here, which can be useful for debugging. |
None
|
drop_last |
bool
|
Whether to drop the last batch if the last batch is incomplete. |
False
|
pad_value |
Optional[Union[int, float]]
|
The padding value if batch padding is needed. None indicates that no padding is needed. NOTE: This argument is only applicable when using a FastEstimator Dataset. |
None
|
collate_fn |
Optional[Callable]
|
Function to merge data into one batch with input being list of elements. |
None
|
Source code in fastestimator\fastestimator\pipeline.py
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 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 |
|
benchmark
¶
Benchmark the pipeline processing speed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mode |
str
|
The execution mode to benchmark. This can be 'train', 'eval' or 'test'. |
'train'
|
epoch |
int
|
The epoch index to benchmark. Note that epoch indices are 1-indexed. |
1
|
num_steps |
int
|
The maximum number of steps over which to perform the benchmark. |
1000
|
log_interval |
int
|
The logging interval. |
100
|
Source code in fastestimator\fastestimator\pipeline.py
get_epochs_with_data
¶
Get a set of epoch indices that contains data given mode.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
total_epochs |
int
|
Total number of epochs. |
required |
mode |
str
|
Current execution mode. |
required |
Returns:
Type | Description |
---|---|
Set[int]
|
Set of epoch indices. |
Source code in fastestimator\fastestimator\pipeline.py
get_loader
¶
Get a data loader from the Pipeline for a given mode
and epoch
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mode |
str
|
The execution mode for the loader. This can be 'train', 'eval' or 'test'. |
required |
epoch |
int
|
The epoch index for the loader. Note that epoch indices are 1-indexed. |
1
|
shuffle |
Optional[bool]
|
Whether to shuffle the data. If None, the value for shuffle is based on mode. NOTE: This argument is only used with FastEstimator Datasets. |
None
|
Returns:
Type | Description |
---|---|
Union[DataLoader, tf.data.Dataset]
|
A data loader for the given |
Source code in fastestimator\fastestimator\pipeline.py
get_modes
¶
Get the modes for which the Pipeline has data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
epoch |
Optional[int]
|
The current epoch index |
None
|
Returns:
Type | Description |
---|---|
Set[str]
|
The modes for which the Pipeline has data. |
Source code in fastestimator\fastestimator\pipeline.py
get_results
¶
Get sample Pipeline outputs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mode |
str
|
The execution mode in which to run. This can be "train", "eval", or "test". |
'train'
|
epoch |
int
|
The epoch index to run. Note that epoch indices are 1-indexed. |
1
|
num_steps |
int
|
Number of steps (batches) to get. |
1
|
shuffle |
bool
|
Whether to use shuffling. |
False
|
Returns:
Type | Description |
---|---|
Union[List[Dict[str, Any]], Dict[str, Any]]
|
A list of batches of Pipeline outputs. |
Source code in fastestimator\fastestimator\pipeline.py
get_scheduled_items
¶
Get a list of items considered for scheduling.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mode |
str
|
Current execution mode. |
required |
Returns:
Type | Description |
---|---|
List[Any]
|
List of schedulable items in Pipeline. |
Source code in fastestimator\fastestimator\pipeline.py
transform
¶
Apply all pipeline operations on a given data instance for the specified mode
and epoch
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
Dict[str, Any]
|
Input data in dictionary format. |
required |
mode |
str
|
The execution mode in which to run. This can be "train", "eval", "test" or "infer". |
required |
epoch |
int
|
The epoch index to run. Note that epoch indices are 1-indexed. |
1
|
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
The transformed data. |