orcanet_contrib.orca_handler_util

Michael’s orcanet utility stuff.

Module Contents

Functions

update_objects(orga, model_file)

Update the organizer for using the model.

orca_sample_modifiers(name)

Returns one of the sample modifiers used for Orca networks.

orca_label_modifiers(name)

Returns one of the label modifiers used for Orca networks.

orca_dataset_modifiers(name)

Returns one of the dataset modifiers used for predicting with OrcaNet.

dict_to_recarray(data_dict)

Convert a dict with 2d np arrays to a 2d struc array, with column

orca_learning_rates(name, total_file_no)

Returns one of the learning rate schedules used for Orca networks.

orcanet_contrib.orca_handler_util.update_objects(orga, model_file)[source]

Update the organizer for using the model.

Look up and load in the respective sample-, label-, and dataset- modifiers, as well as the custom objects. Will assert that the respective objects have not already been set to a non-default value (nothing is overwritten).

Parameters
orgaobject Organizer

Contains all the configurable options in the OrcaNet scripts.

model_filestr

Path to a toml file which has the infos about which modifiers to use.

orcanet_contrib.orca_handler_util.orca_sample_modifiers(name)[source]

Returns one of the sample modifiers used for Orca networks.

They will permute columns, and/or add permuted columns to xs.

The input to the functions is:
xs_filesdict

Dict that contains the input samples from the file(s). The keys are the names of the inputs in the toml list file. The values are a single batch of data from each corresponding file.

The output is:
xs_layerdict

Dict that contains the input samples for a Keras NN. The keys are the names of the input layers of the network. The values are a single batch of data for each input layer.

Parameters
nameNone/str

Name of the sample modifier to return.

Returns
sample_modifierfunction

The sample modifier function.

orcanet_contrib.orca_handler_util.orca_label_modifiers(name)[source]

Returns one of the label modifiers used for Orca networks.

CAREFUL: y_values is a structured numpy array! if you use advanced numpy indexing, this may lead to errors. Let’s suppose you want to assign a particular value to one or multiple elements of the y_values array.

E.g. y_values[1][‘bjorkeny’] = 5 This works, since it is basic indexing.

Likewise, y_values[1:3][‘bjorkeny’] = 5 works as well, because basic indexing gives you a view (!).

Advanced indexing though, gives you a copy. So this y_values[[1,2,4]][‘bjorkeny’] = 5 will NOT work! Same with boolean indexing, like

bool_idx = np.array([True,False,False,True,False]) # if len(y_values) = 5 y_values[bool_idx][‘bjorkeny’] = 10 This will NOT work as well!!

Instead, use np.place(y_values[‘bjorkeny’], bool_idx, 10) This works.

Parameters
namestr

Name of the label modifier that should be used.

Returns
label_modifierfunction

The label modifier function.

orcanet_contrib.orca_handler_util.orca_dataset_modifiers(name)[source]

Returns one of the dataset modifiers used for predicting with OrcaNet.

Parameters
namestr

Name of the dataset modifier that should be used.

orcanet_contrib.orca_handler_util.dict_to_recarray(data_dict)[source]

Convert a dict with 2d np arrays to a 2d struc array, with column names derived from the dict keys.

Parameters
data_dictdict

Keys: name of the output layer. Values: 2d arrays, first dimension matches

Returns
recarrayndarray
orcanet_contrib.orca_handler_util.orca_learning_rates(name, total_file_no)[source]

Returns one of the learning rate schedules used for Orca networks.

Parameters
namestr

Name of the schedule.

total_file_noint

How many files there are to train on.

Returns
learning_ratefunction

The learning rate schedule.