:py:mod:`evoaug_tf.evoaug` ========================== .. py:module:: evoaug_tf.evoaug .. autoapi-nested-parse:: Model (implemented in Tensorflow) demonstrating how to use augmentations during training. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: evoaug_tf.evoaug.RobustModel Functions ~~~~~~~~~ .. autoapisummary:: evoaug_tf.evoaug.augment_max_len .. py:class:: RobustModel(model_func, input_shape=None, augment_list=[], max_augs_per_seq=2, hard_aug=False, finetune=False, inference_aug=False, **kwargs) Bases: :py:obj:`tensorflow.keras.Model` Tensorflow keras.Model to specify how augmentation should be applied to a model :param model: Keras model. :type model: keras.Model :param augment_list: List of data augmentations, each a callable class from augment.py Default is empty list -- no augmentations. :type augment_list: list :param max_augs_per_seq: Maximum number of augmentations to apply to each sequence. Value is superceded by the number of augmentations in augment_list. :type max_augs_per_seq: int :param hard_aug: Flag to set a hard number of augmentations, otherwise the number of augmentations is set randomly up to max_augs_per_seq, default is True. :type hard_aug: bool :param finetune: Flag to turn off augmentations during training, default is False. :type finetune: bool :param inference_aug: Flag to turn on augmentations during inference, default is False. :type inference_aug: bool .. py:method:: build_model(input_shape) .. py:method:: call(inputs, training=False) .. py:method:: train_step(data) .. py:method:: test_step(batch) .. py:method:: predict_step(batch) .. py:method:: _apply_augment(x) Apply augmentations to each sequence in batch, x. .. py:method:: _pad_end(x) Add random DNA padding of length insert_max to the end of each sequence in batch. .. py:method:: finetune_mode(optimizer=None, lr=None) Turn on finetune flag -- no augmentations during training. .. py:method:: save_weights(filepath) .. py:method:: load_weights(filepath) .. py:function:: augment_max_len(augment_list) Determine whether insertions are applied to determine the insert_max, which will be applied to pad other sequences with random DNA. :param augment_list: List of augmentations. :type augment_list: list :returns: Value for insert max. :rtype: int