You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: plasma/models/loader.py
+80-89Lines changed: 80 additions & 89 deletions
Original file line number
Diff line number
Diff line change
@@ -14,16 +14,40 @@
14
14
fromplasma.primitives.shotsimportShot
15
15
16
16
classLoader(object):
17
+
'''
18
+
A Python class to ...
19
+
20
+
The length of shots in e.g. JET data varies by orders of magnitude. For data parallel
21
+
synchronous training it is essential that amounds of train data passed to the model replica is about the same size.
22
+
Therefore, a patching technique is introduced.
23
+
24
+
A patch is a subset of shot's time/signal profile having a fixed length, equal among all patches.
25
+
Patch size is approximately equal to the minimum shot length. More precisely: it is equal
26
+
to the max(1, min_len//rnn_length)*rnn_length - the largest number less or equal to the minimum shot length divisible by the LSTM model length. If minimum shot length is less than the rnn_length, then the patch length is equal to the rnn_length
27
+
'''
28
+
17
29
def__init__(self,conf,normalizer=None):
18
30
self.conf=conf
19
31
self.stateful=conf['model']['stateful']
20
32
self.normalizer=normalizer
21
33
self.verbose=True
22
34
23
35
deftraining_batch_generator(self,shot_list):
24
-
"""Iterates indefinitely over the data set and returns one batch of data at a time.
25
-
Can be inefficient during distributed training because one process loading data will
26
-
cause all other processes to stall."""
36
+
"""
37
+
The method implements a training batch generator as a Python generator with a while-loop.
38
+
It iterates indefinitely over the data set and returns one mini-batch of data at a time.
39
+
40
+
NOTE: Can be inefficient during distributed training because one process loading data will
41
+
cause all other processes to stall.
42
+
43
+
Argument list:
44
+
- shot_list:
45
+
46
+
Returns:
47
+
- One mini-batch of data and label as a Numpy array: X[start:end],y[start:end]
48
+
- reset_states_now: boolean flag indicating when to reset state during stateful RNN training
49
+
- num_so_far,num_total: number of samples generated so far and the total dataset size as per shot_list
A patch is a subset of shot's time/signal profile having a fixed length, equal among all patches.
238
+
Patch size is approximately equal to the minimum shot length. More precisely: it is equal
239
+
to the max(1, min_len//rnn_length)*rnn_length - the largest number less or equal to the minimum shot length divisible by the LSTM model length. If minimum shot length is less than the rnn_length, then the patch length is equal to the rnn_length
240
+
241
+
Since shot lengthes are not multiples of the minimum shot length in general,
242
+
some non-deterministic fraction of patches is created. See:
243
+
244
+
Deterministic patching:
245
+
246
+
Random patching:
247
+
248
+
249
+
Argument list:
250
+
- signals: a list of 1D Numpy array of doubles containing signal values (a plasma property).
251
+
Numpy arrays are shot-sized
252
+
- results: a list of 1D Numpy array of doubles containing disruption times or -1 if a shot
253
+
is non-disruptive. Numpy arrays are shot-sized
254
+
255
+
NOTE: signals and results are parallel lists. Since Arrays are shot-sized, the shape veries across the list
256
+
257
+
Returns:
258
+
- sig_patches_det + sig_patches_rand: (concatenated) list of 1D Numpy arrays of doubles containing signal values.
259
+
Numpy arrays are patch-sized
260
+
- res_patches_det + res_patches_rand: (concatenated) a list of 1D Numpy array of doubles containing disruption times
261
+
or -1 if a shot is non-disruptive. Numpy arrays are patch-sized
262
+
NOTE: sig_patches_det + sig_patches_rand and res_patches_det + res_patches_rand are prallel lists
Currently used callbacks include: BaseLogger, CSVLogger, EarlyStopping.
292
+
Other possible callbacks to add in future: RemoteMonitor, LearningRateScheduler
293
+
294
+
Argument list:
295
+
- conf: There is a "callbacks" section in conf.yaml file. Relevant parameters are:
296
+
list: Parameter specifying additional callbacks, read in the driver script and passed as an argument of type list (see next arg)
297
+
metrics: List of quantities monitored during training and validation
298
+
mode: one of {auto, min, max}. The decision to overwrite the current save file is made based on either the maximization or the minimization of the monitored quantity. For val_acc, this should be max, for val_loss this should be min, etc. In auto mode, the direction is automatically inferred from the name of the monitored quantity.
299
+
monitor: Quantity used for early stopping, has to be from the list of metrics
300
+
patience: Number of epochs used to decide on whether to apply early stopping or continue training
301
+
- callbacks_list: uses callbacks.list configuration parameter, specifies the list of additional callbacks
0 commit comments