Simulai batching
Batching operations #
BatchwiseSampler #
Source code in simulai/batching.py
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 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 |
|
__init__(dataset=None, input_variables=None, target_variables=None, input_normalizer=None, target_normalizer=None, channels_first=None)
#
Batchwise sampler for loading samples from disk and apply normalization if needed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset |
Group
|
Dataset object containing the samples (Default value = None) |
None
|
input_variables |
List[str]
|
List of input variables to be loaded (Default value = None) |
None
|
target_variables |
List[str]
|
List of target variables to be loaded (Default value = None) |
None
|
input_normalizer |
callable
|
Function to be applied on the input variables (Default value = None) |
None
|
target_normalizer |
callable
|
Function to be applied on the target variables (Default value = None) |
None
|
channels_first |
bool
|
Whether the data should be in channels_first format or not. If not provided, will be set to None. (Default value = None) |
None
|
Source code in simulai/batching.py
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 |
|
input_data(indices=None)
#
Retrieve the input data for the given indices, apply normalization and adjust the dimension
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indices |
ndarray
|
The indices of samples for which the input data should be retrieved (Default value = None) |
None
|
Returns:
Type | Description |
---|---|
Tensor
|
A torch tensor of input data: |
Source code in simulai/batching.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
|
input_shape()
#
Get the input shape of the dataset. The shape will be adjusted to put the channels dimension first if 'channels_first' is True.
Returns:
Type | Description |
---|---|
list
|
A list of integers representing the shape of the input variables.: |
Source code in simulai/batching.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
minmax(batch_size=None, data_interval=None)
#
Evaluate the minimum and maximum values of all the target variables in the dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch_size |
int
|
Number of samples to use in the evaluation (Default value = None) |
None
|
data_interval |
list
|
List of 2 integers representing the starting and ending indexes of the interval in which the values will be evaluated. (Default value = None) |
None
|
Returns:
Type | Description |
---|---|
Tuple[float, float]
|
A tuple of minimum and maximum value of the target variables.: |
Source code in simulai/batching.py
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 |
|
target_data(indices=None)
#
Retrieve the target data for the given indices, apply normalization and adjust the dimension
Parameters:
Name | Type | Description | Default |
---|---|---|---|
indices |
ndarray
|
The indices of samples for which the target data should be retrieved (Default value = None) |
None
|
Returns:
Type | Description |
---|---|
Tensor
|
A torch tensor of target data: |
Source code in simulai/batching.py
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
|
batchdomain_constructor #
Create a list of indices of the input data in the form of batches, using either an interval or a list of indices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_interval |
list
|
A list of two integers representing the start and end of the data interval. (Default value = None) |
None
|
batch_size |
int
|
The desired size of the batches (Default value = None) |
None
|
batch_indices |
list
|
A list of indices to be divided into batches. (Default value = None) |
None
|
Returns:
Type | Description |
---|---|
list
|
A list of lists containing the indices of the input data in the form of batches.: |
Source code in simulai/batching.py
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 |
|