PPPLDeepLearning / plasma-python

PPPL deep learning disruption prediction package
http://tigress-web.princeton.edu/~alexeys/docs-web/html/
79 stars 43 forks source link

Signal augmentation #20

Closed ASvyatkovskiy closed 6 years ago

ASvyatkovskiy commented 6 years ago

This PR introduces signal augmentation. During inference, a specific signal (one at a time) is augmented based on the string supplied in the config file conf['data']['signal_to_augment'] (string or None). During training, augment a random signal (again, one at a time) or do not augment at all (conf['data']['augment_during_training']).

Augmentation can either be a random normal noise or zeroing a signal.

The augmentation is implemented as a class hierarchy - a base class AbstractAugmentator and currently only one derived class Augmentator in a dedicated module plasma.preprocessor.augment. Augmentator class uses object composition and defines a data member of type Normalizer. So augmentator wraps normalizer and applies normalization to a shot before augmenting it.

To use in the driver script first create a normalizer object, and then pass it to Augmentator:

from plasma.preprocessor.normalize import Normalizer
from plasma.preprocessor.augment import Augmentator
from plasma.models.loader import Loader
from plasma.conf import conf

raw_normalizer = Normalizer(conf)
raw_normalizer.train()
is_inference= False
normalizer = Augmentator(raw_normalizer,is_inference,conf)
loader = Loader(conf,normalizer)

Switch to inference mode after training of the NN model is complete:

normalizer.set_inference(True)

Create a dedicated example mpi_augment_learn.py driver script to worry less about defaults of augmentation specific config parameters.

Side change: switch from shutil to os.system to perform bash commands, and fixes to tune_hyperparameter.py