umami.tf_tools package#

Submodules#

umami.tf_tools.convert_to_record module#

Module converting h5 to tf records.

class umami.tf_tools.convert_to_record.H5ToTFRecords(config)#

Bases: object

h5 converter to tf records.

load_h5file_train()#

load the numbers of entries given by the chunk size for the jets, tracks and labels from train file.

Yields:
  • X_jets (array_like) – Training jets

  • X_trks (array_like) – Training tracks

  • Y_jets (array_like) – Training jet labels

  • Y_trks (array_like) – Training track labels

  • Weights (array_like) – Training weights

  • X_Add_Vars (array_like) – Conditional variables for CADS and Umami Cond Att.

save_parameters(record_dir)#

write metadata into metadata.json and save it with tf record files

Parameters:

record_dir (str) – directory where metadata should be saved

write_tfrecord()#

write inputs and labels of train file into a TFRecord

umami.tf_tools.generators module#

Data generator module to handle reading of training datasets.

class umami.tf_tools.generators.CadsGenerator(train_file_path: str, y_name: str, n_jets: int, batch_size: int, sample_weights: bool, chunk_size: int = 100000.0, x_name: str | None = None, x_trk_name: str | None = None, excluded_var: list | None = None, n_conds: int | None = None, print_logger: bool = False)#

Bases: ModelGenerator

Generator class for CADS.

This class provides the a generator that loads the training dataset for CADS.

class umami.tf_tools.generators.DipsGenerator(train_file_path: str, y_name: str, n_jets: int, batch_size: int, sample_weights: bool, chunk_size: int = 100000.0, x_name: str | None = None, x_trk_name: str | None = None, excluded_var: list | None = None, n_conds: int | None = None, print_logger: bool = False)#

Bases: ModelGenerator

Generator class for DIPS.

This class provides the a generator that loads the training dataset for DIPS.

class umami.tf_tools.generators.Dl1Generator(train_file_path: str, y_name: str, n_jets: int, batch_size: int, sample_weights: bool, chunk_size: int = 100000.0, x_name: str | None = None, x_trk_name: str | None = None, excluded_var: list | None = None, n_conds: int | None = None, print_logger: bool = False)#

Bases: ModelGenerator

Generator class for DL1*.

This class provides the a generator that loads the training dataset for DL1*.

class umami.tf_tools.generators.ModelGenerator(train_file_path: str, y_name: str, n_jets: int, batch_size: int, sample_weights: bool, chunk_size: int = 100000.0, x_name: str | None = None, x_trk_name: str | None = None, excluded_var: list | None = None, n_conds: int | None = None, print_logger: bool = False)#

Bases: object

Base class for the generators of the datasets for the models.

This class provides the base functionalites for the different models to load the dataset.

get_n_dim()#

This function loads the necessary data into memory and retrieves the number of dimensions of the labels. It does not load jets or tracks.

Returns:

The number of dimensions of the labels.

Return type:

int

get_n_jet_features()#

This function loads the necessary data into memory and retrieves the number of features for the jets. It does not load tracks.

Returns:

The number of jet features.

Return type:

int

get_n_jets()#

Get the number of jets.

Returns:

The number of jets.

Return type:

int

get_n_trk_features()#

This function loads the necessary data into memory and retrieves the number of features for the tracks. It does not load jets.

Returns:

The number of track features.

Return type:

int

get_n_trks()#

This function loads the necessary data into memory and retrieves the number of tracks. It does not load jets.

Returns:

The number of tracks.

Return type:

int

load_in_memory(load_jets: bool, load_tracks: bool, part: int = 0)#

Load the jets or tracks or both step by step in memory.

Parameters:
  • load_jets (bool) – Define, if jets are loaded or not.

  • load_tracks (bool) – Define, if tracks are loaded or not.

  • part (int) – Part of the data which is to be loaded.

Raises:

ValueError – If X_Name or X_trk_Name are not given when requesting jets or tracks, respectively.

class umami.tf_tools.generators.UmamiConditionGenerator(train_file_path: str, y_name: str, n_jets: int, batch_size: int, sample_weights: bool, chunk_size: int = 100000.0, x_name: str | None = None, x_trk_name: str | None = None, excluded_var: list | None = None, n_conds: int | None = None, print_logger: bool = False)#

Bases: ModelGenerator

Generator class for UMAMI with conditional attention.

This class provides the a generator that loads the training dataset for UMAMI with conditional attention.

class umami.tf_tools.generators.UmamiGenerator(train_file_path: str, y_name: str, n_jets: int, batch_size: int, sample_weights: bool, chunk_size: int = 100000.0, x_name: str | None = None, x_trk_name: str | None = None, excluded_var: list | None = None, n_conds: int | None = None, print_logger: bool = False)#

Bases: ModelGenerator

Generator class for UMAMI.

This class provides the a generator that loads the training dataset for UMAMI.

umami.tf_tools.layers module#

Implementations by Johnny Raine

class umami.tf_tools.layers.Attention(*args, **kwargs)#

Bases: Layer

Define Attention Layer.

call(inputs, mask: float | None = None)#

Return the output of the network for a given input.

Parameters:
  • inputs (object) – Input to layer.

  • mask (float, optional) – Mask value, by default None

Returns:

Layer output.

Return type:

output

compute_mask(inputs, mask: float | None = None)#

Compute mask.

Parameters:
  • inputs (object) – Layer input.

  • mask (float) – Custom mask value (needed in tensorflow).

Returns:

Masking for the given input.

Return type:

masking

get_config()#

Return the settings of the network.

Returns:

Dict with the config settings.

Return type:

dict

class umami.tf_tools.layers.AttentionPooling(*args, **kwargs)#

Bases: Layer

Define Attention Pooling Layer.

call(inputs)#

Return the output of the layer for a given input.

Parameters:

inputs (object) – Input to layer.

Returns:

Layer output.

Return type:

output

class umami.tf_tools.layers.ConditionalAttention(*args, **kwargs)#

Bases: Layer

Define custom conditional attention layer. This uses the standard attention with a condition to further improve the attention weighing.

call(inputs)#

Return the output of the network for a given input.

Parameters:

inputs (object) – Input to layer.

Returns:

Layer output.

Return type:

output

compute_mask(inputs, mask: float | None = None)#

Compute the masking.

Parameters:
  • inputs (object) – Input to a layer.

  • mask (float) – Custom mask value (needed in tensorflow).

Returns:

Return correct masking

Return type:

masking

get_config()#

Return the settings of the network.

Returns:

Dict with the config settings.

Return type:

dict

class umami.tf_tools.layers.ConditionalDeepSet(*args, **kwargs)#

Bases: Layer

Keras layer for conditional deep set.

call(inputs)#

Return the output of the layer for a given input.

Parameters:

inputs (object) – Input to layer.

Returns:

Layer output.

Return type:

output

compute_mask(inputs, mask: float | None = None)#

Compute the masking.

Parameters:
  • inputs (object) – Input to a layer.

  • mask (float) – Custom mask value (needed in tensorflow).

Returns:

Return correct masking

Return type:

masking

get_config()#

Return the settings of the network.

Returns:

Dict with the config settings.

Return type:

dict

class umami.tf_tools.layers.DeepSet(*args, **kwargs)#

Bases: Layer

Define a deep set layer for easier usage.

call(inputs, mask: float | None = None)#

Return the output of the network for a given input.

Parameters:
  • inputs (object) – Input to layer.

  • mask (float, optional) – Mask value, by default None

Returns:

Layer output.

Return type:

output

compute_mask(inputs, mask: float | None = None)#

Compute the masking.

Parameters:
  • inputs (object) – Input to a layer.

  • mask (float) – Custom mask value (needed in tensorflow).

Returns:

Return correct masking

Return type:

masking

get_config()#

Return the settings of the network.

Returns:

Dict with the config settings.

Return type:

dict

class umami.tf_tools.layers.DenseNet(*args, **kwargs)#

Bases: Layer

Define a DenseNet as a layer to easier access it.

call(inputs)#

Define what happens when the layer is called

Parameters:

inputs (object) – Input to the network.

Returns:

output – Output of the network. Depending on class_output_only, either a tuple with the classification and last layer output is returned () or only the classification output (True)

Return type:

object

get_config() dict#

Return the settings of the network.

Returns:

Dict with the config settings.

Return type:

dict

class umami.tf_tools.layers.MaskedAverage1DPooling(*args, **kwargs)#

Bases: Layer

Keras layer for masked 1D average pooling.

call(inputs, mask: float | None = None)#

Return the output of the layer for a given input.

Parameters:
  • inputs (object) – Input to layer.

  • mask (float, optional) – Mask value, by default None

Returns:

Layer output.

Return type:

output

class umami.tf_tools.layers.MaskedSoftmax(*args, **kwargs)#

Bases: Layer

Softmax layer with masking.

call(inputs, mask: float | None = None)#

Return the output of the softmax layer.

Parameters:
  • inputs (object) – Layer input.

  • mask (float, optional) – Masking value, by default None

Returns:

Return output of the layer.

Return type:

output

compute_mask(inputs, mask: float | None = None)#

Compute mask.

Parameters:
  • inputs (object) – Layer input.

  • mask (float) – Custom mask value (needed in tensorflow).

Returns:

Masking for the given input.

Return type:

masking

get_config()#

Return the settings of the network.

Returns:

Dict with the config settings.

Return type:

dict

class umami.tf_tools.layers.Sum(*args, **kwargs)#

Bases: Layer

Simple sum layer. The tricky bits are getting masking to work properly, but given that time distributed dense layers _should_ compute masking on their own.

Author: Dan Guest https://github.com/dguest/flow-network/blob/master/SumLayer.py

build(input_shape)#

Build step which is skipped.

Parameters:

input_shape (object) – Input shape of the layer (is needed in tensorflow).

call(x, mask: float | None = None)#

Return the output of the layer.

Parameters:
  • x (object) – Layer input

  • mask (float, optional) – Mask value, by default None

Returns:

Output of the layer

Return type:

output

compute_mask(inputs, mask)#

Compute masking

Parameters:
  • inputs (object) – Layer input.

  • mask (float) – Custom mask value (needed in tensorflow).

Returns:

Return the masking

Return type:

masking

compute_output_shape(input_shape)#

Compute the output shape.

Parameters:

input_shape (object) – Layer input shape

Returns:

Layer output.

Return type:

output

umami.tf_tools.load_tfrecord module#

Reader for tf records datasets.

class umami.tf_tools.load_tfrecord.TFRecordReader(path: str, batch_size: int, nfiles: int, tagger_name: str, tracks_name: str | None = None, use_track_labels: bool = False, sample_weights: bool = False, n_cond: int | None = None)#

Bases: object

Reader for tf records datasets.

decode_fn(record_bytes)#

Convert serialised Dataset to dictionary and return inputs and labels

Parameters:

record_bytes (serialised object) – serialised Dataset

Returns:

  • inputs (dict) – Dictionary of tf_data of jet and track inputs

  • labels (tf_data) – tf data stream of labels

Raises:
  • KeyError – If given track selection not in metadata.

  • KeyError – If no conditional info is found in metadata.

  • ValueError – If tagger type is not supported.

load_dataset()#

Load TFRecord and create Dataset for training

Return type:

tf_Dataset

umami.tf_tools.load_tfrecord.load_tfrecords_train_dataset(train_config: object)#

Load the train dataset from tfrecords files.

Parameters:

train_config (object) – Loaded train config.

Returns:

  • train_dataset (tfrecord.Dataset) – Loaded train dataset from tfrecords.

  • metadata (dict) – Dict with the metadata infos of the train dataset.

Raises:
  • ValueError – If one of the given input files is not a tfrecords file.

  • KeyError – if the metadata json file is not in the train directory.

umami.tf_tools.models module#

Implementations by Johnny Raine

umami.tf_tools.models.deepsets_model(repeat_input_shape, num_conditions: int, num_set_features: int, sets_nodes: list, classif_nodes: list, classif_output: int, pooling: str = 'Max', attention_nodes: list | None = None, condition_sets: bool = True, condition_attention: bool = True, condition_classifier: bool = True, shortcut_inputs: bool = True, sets_batch_norm: bool = False, classif_batch_norm: bool = False, activation: str = 'relu', attention_softmax: bool = True)#

Keras implementation for deep sets

Parameters:
  • repeat_input_shape (tuple) – Input shape of the set data. For CADS, this would be the shape of the input to the deep sets part.

  • num_conditions (int) – Number of conditions used for training.

  • num_set_features (int) – Number of neurons of the last layer of the deep set.

  • sets_nodes (list) – List with the number of neurons for the deep sets hidden layers.

  • classif_nodes (list) – List with the number of neurons for the classification network (the F network after the deep sets part).

  • classif_output (int) – Number of output neurons of the classification network (Number of classes used).

  • pooling (str, optional) – poolig operation, by default “Max”

  • attention_nodes (list, optional) – List of hidden layer neurons for the attention block, by default None.

  • condition_sets (bool, optional) – Decide, if the conditional information is folded into the input of the deep sets block, by default True.

  • condition_attention (bool, optional) – Decide, if the conditional information is folded into the input of the attention block, by default True

  • condition_classifier (bool, optional.) – Decide, if the conditional information is folded into the input of the classification block, by default True

  • shortcut_inputs (bool, optional) – Decide, if the deep sets inputs are short cutted (Adding it again after the deep sets block to the output of the deep sets block), by default True.

  • sets_batch_norm (bool, optional) – Decide, if batch normalisation is used in the deep sets block, by default False.

  • classif_batch_norm (bool, optional) – Decide, if batch normalisation is used in the classification block, by default False.

  • activation (str, optional) – Decide, which activation function is used, by default “relu”.

  • attention_softmax (bool, optional) – Decide, if the output of the attention block is calculated using a sigmoid activation (False) or a Softmax activation (True), by default True.

Returns:

Model for deep sets training

Return type:

keras model

umami.tf_tools.models.deepsets_model_umami(trk_input_shape, jet_input_shape, num_conditions, num_set_features, dips_sets_nodes, f_classif_nodes, classif_output, intermediate_units, dl1_units, pooling: str = 'attention', attention_nodes: list | None = None, condition_sets: bool = True, condition_attention: bool = True, condition_classifier: bool = True, shortcut_inputs: bool = True, sets_batch_norm: bool = False, classif_batch_norm: bool = False, activation: str = 'relu', attention_softmax: bool = True)#

Keras implementation for umami with conditional attention

Parameters:
  • trk_input_shape (tuple) – Input shape of the set data. For UMAMI with conditional attention, this would be the shape of the input to the deep sets part.

  • jet_input_shape (tuple) – Input shape of the jet data.

  • num_conditions (int) – Number of conditions used for training.

  • num_set_features (int) – Number of neurons of the last layer of the deep set.

  • dips_sets_nodes (list) – List with the number of neurons for the deep sets hidden layers.

  • f_classif_nodes (list) – List with the number of neurons for the classification network (the F network after the deep sets part).

  • classif_output (int) – Number of output neurons of the classification network (Number of classes used).

  • intermediate_units (list) – List with the number of neurons for the intermediate layer used for jet features

  • dl1_units (list) – List with the number of neurons for the DL1r hidden layers.

  • pooling (str, optional) – poolig operation, by default “Max”

  • attention_nodes (list, optional) – List of hidden layer neurons for the attention block, by default None.

  • condition_sets (bool, optional) – Decide, if the conditional information is folded into the input of the deep sets block, by default True.

  • condition_attention (bool, optional) – Decide, if the conditional information is folded into the input of the attention block, by default True

  • condition_classifier (bool, optional.) – Decide, if the conditional information is folded into the input of the classification block, by default True

  • shortcut_inputs (bool, optional) – Decide, if the deep sets inputs are short cutted (Adding it again after the deep sets block to the output of the deep sets block), by default True.

  • sets_batch_norm (bool, optional) – Decide, if batch normalisation is used in the deep sets block, by default False.

  • classif_batch_norm (bool, optional) – Decide, if batch normalisation is used in the classification block, by default False.

  • activation (str, optional) – Decide, which activation function is used, by default “relu”.

  • attention_softmax (bool, optional) – Decide, if the output of the attention block is calculated using a sigmoid activation (False) or a Softmax activation (True), by default True.

Returns:

Model for umami with conditional attention training

Return type:

keras model

umami.tf_tools.models.prepare_model(train_config: object)#

Prepare the keras model.

Parameters:

train_config (object) – Loaded train config file.

Returns:

  • model – Loaded keras model (either the latest model for continuation or the given one).

  • init_epoch – Internal epoch number for the training. If the training is continued, this is the number of the lastest trained epoch (this is so that when the training starts, epoch 1 is not overwritten).

  • load_optimiser – Decide, if the optimiser of the model is loaded (True) or if the model will be recompiled.

Raises:

ValueError – If load_optimiser is True and no model file is given.

umami.tf_tools.tddgenerators module#

Data generator module to handle reading of TDD datasets rescaling them and rearranging for training of models.

class umami.tf_tools.tddgenerators.TDDCadsGenerator(train_file_path: str, n_jets: int, batch_size: int, sample_weights: bool, config_file: str, tracks_name: str | None = None, chunk_size: int = 100000.0, excluded_var: list | None = None, n_conds: int | None = None, print_logger: bool = False, use_validation_samples: bool = False, old_scaling_functions: bool = False)#

Bases: TDDGenerator, CadsGenerator

Generator class for CADS.

This class provides the a generator that loads the TDD dataset for CADS.

class umami.tf_tools.tddgenerators.TDDDipsGenerator(train_file_path: str, n_jets: int, batch_size: int, sample_weights: bool, config_file: str, tracks_name: str | None = None, chunk_size: int = 100000.0, excluded_var: list | None = None, n_conds: int | None = None, print_logger: bool = False, use_validation_samples: bool = False, old_scaling_functions: bool = False)#

Bases: TDDGenerator, DipsGenerator

Generator class for DIPS.

This class provides the a generator that loads the TDD dataset for DIPS.

class umami.tf_tools.tddgenerators.TDDDl1Generator(train_file_path: str, n_jets: int, batch_size: int, sample_weights: bool, config_file: str, tracks_name: str | None = None, chunk_size: int = 100000.0, excluded_var: list | None = None, n_conds: int | None = None, print_logger: bool = False, use_validation_samples: bool = False, old_scaling_functions: bool = False)#

Bases: TDDGenerator, Dl1Generator

Generator class for DL1*.

This class provides the a generator that loads the TDD dataset for DL1*.

class umami.tf_tools.tddgenerators.TDDGenerator(train_file_path: str, n_jets: int, batch_size: int, sample_weights: bool, config_file: str, tracks_name: str | None = None, chunk_size: int = 100000.0, excluded_var: list | None = None, n_conds: int | None = None, print_logger: bool = False, use_validation_samples: bool = False, old_scaling_functions: bool = False)#

Bases: object

Base class for the generators of the datasets for the models. from the usual TDD format

This class provides the base functionalites for the different models to load the dataset.

calculate_weights(weights_dict: dict, jets: ndarray, labels: ndarray)#

Finds the according weight for the jet, with the weights calculated from the GetFlavorWeights method. Writes it onto the jets[“weight”].

Parameters:
  • weights_dict (dict) –

    weights_dict per flavor and some additional info written into a pickle file at /hybrids/flavour_weights

    • ’bjets’, etc.

    • ’bins_x’ : pt bins

    • ’bins_y’ : eta bins

    • ’bin_indices_flat’ : flattened indices of the bins in the histogram

    • ’label_map’ : {0: ‘ujets’, 1: ‘cjets’, 2: ‘bjets’}

  • jets (np.ndarray) – Containing values of jet variables

  • labels (np.ndarray) – Binarized truth value of flavor for jet with shape (n_jets x (nFlavor x 1))

get_n_dim()#

This function loads the necessary data into memory and retrieves the number of dimensions of the labels. It does not load jets or tracks.

Returns:

The number of dimensions of the labels.

Return type:

int

get_n_jet_features()#

This function loads the necessary data into memory and retrieves the number of features for the jets. It does not load tracks.

Returns:

The number of jet features.

Return type:

int

get_n_jets()#

Get the number of jets.

Returns:

The number of jets.

Return type:

int

get_n_trk_features()#

This function loads the necessary data into memory and retrieves the number of features for the tracks. It does not load jets.

Returns:

The number of track features.

Return type:

int

get_n_trks()#

This function loads the necessary data into memory and retrieves the number of tracks. It does not load jets.

Returns:

The number of tracks.

Return type:

int

get_normalisation_arrays(variables, input_type: str, trk_vars_lists_dict=None)#

Generate normalization arrays for the given variables. This function calculates the mean, standard deviation, and default values for the specified variables based on the provided input type and tracked variables dictionary (if available). It returns a dictionary containing arrays for mean, standard deviation, and default values.

Parameters:
  • variables (list) – A list of variables for which to generate normalization arrays.

  • input_type (str) – The type of input data. Used to select the appropriate scale dictionary.

  • trk_vars_lists_dict (dict, optional) – A dictionary containing lists of tracked variables. The keys represent categories, such as ‘jointNormVars’ or ‘logNormVars’, and the values are the corresponding lists of variables. Defaults to None.

Returns:

A dictionary containing the normalization arrays: - “mean” (numpy.ndarray):

An array of mean values for the given variables.

  • ”std” (numpy.ndarray):

    An array of standard deviation values for the given variables.

  • ”default” (numpy.ndarray):

    An array of default values for the given variables.

Return type:

dict

Notes

If a variable does not have a corresponding entry in the scale dictionary or does not match any tracked variables, it will be assigned default normalization values of mean=0, std=1, and default=0.

get_track_vars()#

Retrieve track variables.

This function retrieves the track variables based on the configuration settings. It returns a list of track variables and a dictionary containing categorized track variable lists.

Returns:

A tuple containing: - trk_vars (list): A list of track variables. - trk_vars_lists_dict (dict):

A dictionary containing categorized track variable lists.

Return type:

tuple

Notes

The track variables are obtained from the variable_config and categorized into three types: “noNormVars”, “logNormVars”, and “jointNormVars”. If a specific variable type is not found in the configuration or is set to None, an empty list will be used as its value.

load_in_memory(load_jets: bool, load_tracks: bool, part: int = 0)#

This function loads jets, labels, tracks, weights, and performs scaling operations. The loaded data is stored in memory for faster access during training or evaluation.

Parameters:
  • load_jets (bool) – A flag indicating whether to load jets into memory.

  • load_tracks (bool) – A flag indicating whether to load tracks into memory.

  • part (int, optional) – The part number of the data to load. Defaults to 0.

scale_input(batch, input_type: str)#

Normalize jet inputs. This function takes a batch of inputs and scales them based on the specified input type. It uses the mean and standard deviation values from the normalization dictionary to normalize the inputs. Any non-finite values in the inputs are replaced with the corresponding default values.

Parameters:
  • batch (numpy.ndarray) – A structured numpy array containing the batch of inputs.

  • input_type (str) – The type of input data. Used to select the appropriate normalization parameters.

Returns:

The normalized inputs as a NumPy array.

Return type:

numpy.ndarray

scale_tracks(trks)#

Scale track variables. This function scales the track variables in the given input based on the normalization parameters and track masks. It applies logarithmic scaling to the variables specified in the logNormVars list. Non-finite values in the input are replaced with appropriate values, and the scaling is performed using the mean and standard deviation values from the normalization dictionary.

Parameters:

trks (numpy.ndarray) – The input track variables to be scaled as a structured array.

Returns:

The scaled track variables as a NumPy array.

Return type:

numpy.ndarray

class umami.tf_tools.tddgenerators.TDDUmamiConditionGenerator(train_file_path: str, n_jets: int, batch_size: int, sample_weights: bool, config_file: str, tracks_name: str | None = None, chunk_size: int = 100000.0, excluded_var: list | None = None, n_conds: int | None = None, print_logger: bool = False, use_validation_samples: bool = False, old_scaling_functions: bool = False)#

Bases: TDDGenerator, UmamiConditionGenerator

Generator class for UMAMI with conditional attention.

This class provides the a generator that loads the TDD dataset for UMAMI with conditional attention.

class umami.tf_tools.tddgenerators.TDDUmamiGenerator(train_file_path: str, n_jets: int, batch_size: int, sample_weights: bool, config_file: str, tracks_name: str | None = None, chunk_size: int = 100000.0, excluded_var: list | None = None, n_conds: int | None = None, print_logger: bool = False, use_validation_samples: bool = False, old_scaling_functions: bool = False)#

Bases: TDDGenerator, UmamiGenerator

Generator class for UMAMI.

This class provides the a generator that loads the TDD dataset for UMAMI.

umami.tf_tools.tddgenerators.filter_dictionary(dictionary, fields)#

Filter a dictionary for a list of fields.

This function takes a dictionary and a list of fields as input. It creates a new dictionary that contains only the key-value pairs where the key is present in the provided fields list.

Parameters:
  • dictionary (dict) – The dictionary to be filtered.

  • fields (list) – A list of fields to filter the dictionary.

Returns:

A filtered dictionary that contains only the specified fields.

Return type:

dict

umami.tf_tools.tddgenerators.get_generator(for_model, arg_dict, train_data_structure=None, small=False)#

Get a generator for the specified model. This function returns a generator object based on the specified model. The generator is created using the provided arguments in the arg_dict. Optionally, the train_data_structure can be provided to customize the training data structure. The small parameter can be set to True to indicate a smaller dataset.

Parameters:
  • for_model (str) – The name or identifier of the model for which to get the generator.

  • arg_dict (dict) – A dictionary containing the arguments for creating the generator.

  • train_data_structure (Optional) – The data structure for training data. Defaults to None.

  • small (bool, optional) – Flag indicating whether to use a small chunk size for loading that is equal to the size of 2 batches. Defaults to False.

Returns:

A generator object for the specified model.

Return type:

generator

Raises:

ValueError – If the specified model is not supported.

umami.tf_tools.tools module#

Helper tools for tensorflow.

umami.tf_tools.tools.get_learning_rate_reducer(nn_structure: NNStructureConfig)#

Call learning rate reducer.

Parameters:

nn_structure (umami.train_tools.configuration.NNStructureConfig) – Loaded train_config nn_structure part

Returns:

learning rate reducer callback

Return type:

callback

Module contents#